Copy Constructor is also a constructor whose main aim is to initialize the variable indirectly.
but here in copy constructor we are passing an object of the same class as a argument.
so, we can copy the value of that object into other one.
class sample
{
int a;
public:
sample()
{
a = 10;
}
sample(&obj)
{
a = obj.a;
}
void show()
{
cout<<a;
}
};
main()
{
sample o1,o2;
o1.show();
o2.show();
}
in both it will print 10 on output screen;