#include<iostream>
using namespace std;
class rect
{
private:
int area;
public:
rect()
{
area=0;
}
rect(int a,int b){
area=a*b;
}
rect(rect &r)
{
area=r.area;
}
void display()
{
cout<<"The area is:"<<area<<endl;
}
};
int main()
{
rect r1;
rect r2(2,6);
rect r3(r2);
r1.display();
r2.display();
r3.display();
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
The area is:0
The area is:12
The area is:12
The area is:12
The area is:12