/* IMPLEMENTATION OF DESTRUCTORS */
#include< iostream.h>
#include< conio.h>
int count = 0;
class data
{
public:
data(void)
{
count++;
cout< < endl< < "The Number of The Object Created Is:"< < count;
}
~data()
{
cout< < endl< < "The Number Of The Object Destroyed Is"< < count;
count--;
}
};
void main()
{
clrscr();
data d1;
data d2;
{
data d3;
data d4;
}
data d5;
data d6;
}
/**********OUTPUT**********
The Number of The Object Created Is: 1
The Number of The Object Created Is: 2
The Number of The Object Created Is: 3
The Number of The Object Created Is: 4
The Number Of The Object Destroyed Is 4
The Number Of The Object Destroyed Is 3
The Number of The Object Created Is: 3
The Number of The Object Created Is: 4
The Number Of The Object Destroyed Is 4
The Number Of The Object Destroyed Is 3
The Number Of The Object Destroyed Is 2
The Number Of The Object Destroyed Is 1
*/
Sunday, February 10, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment