Category : Files from Magazines
Archive   : CUJ9411.ZIP
Filename : CLASS.CPP

 
Output of file : CLASS.CPP contained in archive : CUJ9411.ZIP
LISTING 24 - Illustrates the behavior of class-specific new and
delete (see Listing 23)

// class.cpp
#include
#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;
}



  3 Responses to “Category : Files from Magazines
Archive   : CUJ9411.ZIP
Filename : CLASS.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/