Listing 24 Illustrates the behavior of class-specific new and delete (see Listing 23)

// class.cpp
#include <iostream.h>
#include "t.h"

main()
{
   cout << "allocating a T:" << endl;
   T *t1 = new T;
   cout << endl;

   cout << "allocating an array of 3 T's:" << endl;
   T *t2 = new T[3];
   cout << endl;

   cout << "allocating a T with initialization:" << endl;
   T *t3 = new T(2);
   cout << endl;

   cout << "allocating a U:" << endl;
   U *u1 = new U;
   cout << endl;

   cout << "allocating an array of 2 U's:" << endl;
   U *u2 = new U[2];
   cout << endl;

   cout << "deleting a T:" << endl;
   delete t1;
   cout << endl;

   cout << "deleting the array of 3 T's:" << endl;
   delete [] t2;
   cout << endl;

   cout << "deleting another T:" << endl;
   delete t3;
   cout << endl;

   cout << "deleting the U:" << endl;
   delete u1;
   cout << endl;

   cout << "deleting the array of 2 U's:" << endl;
   delete [] u2;
   cout << endl;

   return 0;
}

// End of File