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.
 

    Discussion

  • Royalsuman   -Posted on 28 Jul 19
    features of copy constructor
  • Munish Babu    -Posted on 14 Jul 18
    It's a best way of learning.
  • abhishek jayaswal   -Posted on 31 Jul 16
    nice

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)