August 2012
Intermediate to advanced
976 pages
30h 17m
English
A constructor is the copy constructor if its first parameter is a reference to the class type and any additional parameters have default values:
class Foo {public: Foo(); // default constructor Foo(const Foo&); // copy constructor // ...};
For reasons we’ll explain shortly, the first parameter must be a reference type. That parameter is almost always a reference to const, although we can define the copy constructor to take a reference to nonconst. The copy constructor is used implicitly in several circumstances. Hence, the copy constructor usually should not be explicit (§ 7.5.4, p. 296).
Read now
Unlock full access