Copy Constructor: It is a constructor, which initializes it's object member variable with another object of the same class. If you don't implement a copy constructor in your class, the compiler automatically does it.
Copy constructors are called in these situations:
i.)when compiler generates a temporary object
ii.)when a function returns an object of that class by value
iii.)when the object of that class is passed by value as an argument to a function
iv.)when you construct an object based on another object of the same class
ii.)when a function returns an object of that class by value
iii.)when the object of that class is passed by value as an argument to a function
iv.)when you construct an object based on another object of the same class
No comments:
Post a Comment