//Destructor
#include <iostream.h>
#include <conio.h>
class Test
{
static int count;
public:
Test()
{
count++;
cout << endl << "object " << count << "created";
}
~Test()
{
cout << endl << "object" << count << "destroyed";
count--;
}
};
int Test :: count = 0;
void main()
{
clrscr();
Test obj1;
{
cout << endl << "within block 1:";
Test obj2;
}
{
cout << endl << "within block 2: ";
Test obj2;
}
getch();
}
Comments
Post a Comment