/********************************************************************************************************
*************Designed and Developed by V2Geeks******************************************
********************************************************************************************************/
// Example of Destructor ( To de-allocate memory).
#include<iostream.h>
#include<conio.h>
int count=0;// Global variable
class Test
{
public:
Test() // default constructor
{
count++;
cout<<"Constructor created= "<<count<<endl;
}
~Test()// Destructor
{
cout<<"Destructor called= "<<count<<endl;
count--;
}
};
void main()
{
cout<<"Enter in main()\n";
Test obj1,obj2,obj3,obj4;
{
//block started
cout<<"\nEnter in Block\n";
Test obj5;
} //First Destructor called here
cout<<"Exit from first block\n";
{
//Another block started
cout<<"\nEnter in second Block\n";
Test obj6
}
cout<<"\n Exit from second block\n";
}