0% found this document useful (0 votes)
2 views1 page

C++ Class Constructors and Destructors

Uploaded by

MD Al Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

C++ Class Constructors and Destructors

Uploaded by

MD Al Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include<iostream>

using namespace std;


class myClass
{
private:
int a,b,c;
public:
myClass()
{
cout<<"I am Default"<<endl;
}
myClass(int x, int y)
{
this->a=x; this->b=y;
cout<<a+b<<endl;
}
myClass(int x, int y, int z)
{
this->a=x; this->b=y; this->c=z;
cout<<a+b+c<<endl;
}
~myClass()
{
cout<<"Destroy"<<endl;
}
};
main()
{
myClass myObj;
myObj = myClass(10,45);
myObj = myClass();
myObj = myClass(45,45,10);
}

You might also like