Copy Constructor:-
It is of the form classname (classname &) and used for the initialization of an
object form another object of same type.
Class fun
{
Float x,y;
Public:
Fun (float a,float b)//constructor
{
x = a;
y = b;
}
Fun (fun &f) //copy constructor
{
cout<<ā\ncopy constructor at work\nā;
X = f.x;
Y = f.y;
}
Void display (void)
{
Cout<<āā<<y<<end1;
}
};
Here we have two constructors, one copy constructor for copying data value of a fun
object to another and other one a parameterized constructor for assignment of initial values
given.