Copy constructor - Features,Definition,Function
Q. A copy constructor is called- Published on 19 Oct 15
a. when an object is returned by value
b. when an object is passed by value as an argument
c. when compiler generates a temporary object
d. all the above
ANSWER: all the above
Copy constructor is a type of constructor which is used for creating a new object that is an exact copy of the existing object. In general compiler creates a copy constructor for each and every class on its own but in special case( when object has pointers involved) copy constructor is created by the programmer. It is called in all the above cases.