Copy Constructor in C++ language
#include<iostream>
using namespace std;
class rect
{
int l,b;
public:
rect(int x,int y)
{
l=x,b=y;
}
rect(rect &x)
{
l=x.l;
b=x.b;
}
void show()
{
cout<<l<<"\n"<<b<<"\n";
}
};
int main()
{
rect r1(10,20),r2(r1);
r1.show();
r2.show();
return 0;
}
Comments
Post a Comment