A copy constructor is used to initialize a newly declared variable from an existing variableA variable is declared which is initialized from another object,A value parameter is initialized from its corresponding argument.f(p); // copy constructor initializes formal value parameter. An object is returned by a function.C++ calls a copy constructor to make a copy of an object in each of the above cases. If there is no copy constructor defined for the class, C++ uses the default copy constructor which copies each field, ie, makes a shallow copy.
The copy constuctor is used to initialize an object by copying the state from another object of the same class. It takes a reference to an object of the same class as itself as an argument.
A copy constructor is invoked when an object is passed by value, returned by value or explicitly copied.