1 // new und delete mit Objektfeld
  2 // Datei: new3.cpp
  3 #include <stdio.h>
  4 #include <stdlib.h>
  5 #include "ratiob1.hpp"
  6
  7 int main ()
  8 {
  9 ratio  * rp, * rpf;
 10 rp = new ratio (2,3);
 11 if (rp == NULL)
 12    printf ("\nFehler."),exit(1);
 13 delete rp;
 14 rpf = new ratio [10];  // Standardkonstruktor
 15 if (rpf == NULL)
 16    printf ("\nFehler."),exit(1);
 17 delete [] rpf;
 18 return 0;
 19 }

Bild 5-8: Anlegen eines Objektes