Friday, 24 August 2012

Constructor and Destructor in C++

#include<iostream.h>
#include<conio.h>
class cse
{
int m,n;
public:
cse()
{
m=0;
n=0;
}
cse(int a,int b)
{
m=a;
n=b;
}
void display()
{
cout<<"\nm="<<m;
cout<<"\nn="<<n;
}
~cse()
{
cout<<"\n destructor is executed";
}
};
void main()
{
cse a;
clrscr();
cse a2(10,20);
a.display();
a2.display();
getch();
}

No comments:

Post a Comment

There was an error in this gadget