source file name: destructor.cpp
#include<iostream.h>
#include<conio.h>
#include<math.h>
int cnt;
class beta
{
public:
beta()
{
cnt++;
cout<<"\n Object created No.: "<< cnt;
}
~beta()
{
cout<<"\n Object destroyed No.: "<< cnt;
cnt--;
}
} ;
void main()
{
clrscr();
cout<<" Constructor and Destructor program"<<endl;
cout<<"\n Main fuction block";
beta b1,b2,b3,b4;
{
cout<<"\n now we are in block: 1"<<endl;
beta b5;
}
{
cout<<"\n now we are in block: 2"<<endl;
beta b6;
}
cout<<"\n re enter Main fuction block";
getch();
}
output:
0 Comments
Post a Comment