Copy semantics
An object keeps state information in its data members, which can themselves be of POD-types or class types. If you do not define a copy constructor for your class, then the compiler implicitly defines one for you. This implicitly-defined copy constructor copies each member in turn, invoking the copy constructor of members of class type and performing a bitwise copy of POD-type members. The same is true of the assignment operator. The compiler generates one if you do not define your own, and it performs member-wise assignment, invoking the assignment operators of member objects of class-type, and performing bitwise copies of POD-type members.
The following example illustrates this:
Listing A.2: Implicit destructor, copy constructor, and assignment operator
1 #include <iostream> 2 3 class Foo { 4 public: 5 Foo() {} 6 7 Foo(const Foo&) { 8 std::cout << "Foo(const Foo&)\n"; 9 } 10 11 ~Foo() { 12 std::cout << "~Foo...