Copy Constructor
26 January, 2013 - 1 min read
The copy constructor is a special kind of constructor which creates a new object which is a copy of an existing one, and does it efficiently.
The copy constructor receives an object of its own class as an argument, and allows to create a new object which is copy of another without building it from scratch.
There are 3 situations in which the copy constructor is called:
- When we make copy of an object.
- When we pass an object as an argument by value to a method.
- When we return an object from a method by value.