#include<iostream.h>
#include<conio.h>
class demo
{
                int x;
public:
                demo()
                                {
                                cout<<"Constructor Is Called"<<endl;
                                x=7;
                                }
                ~demo()
                                {
                                cout<<"Destructor Is Called"<<endl;
                                cout<<"X = "<<x<<endl;
                                getch();
                                }
};
void main()
{
                clrscr();
                demo d;
                cout<<"In Main() Function"<<endl;
}

168.PNG

Advertisements