August 2001
Beginner
482 pages
10h 52m
English
In addition to providing a default constructor and destructor, the compiler provides a default copy constructor. The copy constructor is called every time a copy of an object is made.
When you pass an object by value, either into a function or as a function's return value, a temporary copy of that object is made. If the object is a user-defined object, the class's copy constructor is called.
All copy constructors take one parameter: a reference to an object of the same class. It is a good idea to make it a constant reference, because the constructor will not have to alter the object passed in. For example:
CAT(const CAT & theCat);
Here the CAT constructor takes a constant reference to an existing CAT object. The goal of ...
Read now
Unlock full access