Explain the Copy Constructor.

bookmark

A member function that initializes an object using another object of the same class is known as a copy constructor in C++. They can also be made private. A call to the copy constructor can happen in any of the following 4 scenarios when:

  1. The compiler generates a temporary object
  2. An object is constructed or based on some another object of the same class
  3. An object of the class is returned by value
  4. An object of the class is passed (i.e., to a function) by value as an argument