Copy Constructor 1
-
There are two common situations when an object must be copied implictly:
- When an object is passed to a function as a value parameter
- When an object is returned by a function as a value
IntArray Fun (IntArray a); // prototype
...
IntArray a,b;
b = Fun(a); // copy of argument "a" made when function is called
// copy of return value made as function returns
In addition to at least one where objects are copied explicitly:
- When an object is initialized in a declaration
IntArray a;
...
IntArray b(a); // explicit call to copy constructor - make "b" a copy of "a"