Sunday, January 26, 2014

C++ Program to demonstrate the Destructor Function

with 0 Comment
C++ Program to demonstrate the Destructor Function:

#include<iostream.h>
#include<conio.h>
int count=0;
class alpha
{
public:
alpha()
{
count++;
cout<<"\n No of Objects created"<<count;
}
~alpha()
{
cout<<"\n No of Objects Destroyed"<<count;
count--;
}
};
int main()
{
clrscr();
cout<<"\n Enter main\n";
alpha A1,A2,A3,A4;
{
cout<<"\n Enter Block 1\n";
alpha A5;
}
{
cout<<"\n Enter Block 2\n";
alpha A6;
}
cout<<"\n\n Re-Enter main\n\n";
getch();
}

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive