xxxxxxxxxx
// Example:
#include<iostream>
using namespace std;
int count=0;
class Test
{
public:
Test()
{
count++;
cout<<"\n No. of Object created:\t"<<count;
}
~Test()
{
cout<<"\n No. of Object destroyed:\t"<<count;
--count;
}
};
main()
{
Test t,t1,t2,t3;
return 0;
}
/*
No. of Object created: 1
No. of Object created: 2
No. of Object created: 3
No. of Object created: 4
No. of Object destroyed: 4
No. of Object destroyed: 3
No. of Object destroyed: 2
No. of Object destroyed: 1
*/