October 1999
Beginner
304 pages
7h 11m
English
By default, when we assign one class object with another, as in
Triangular tri1( 8 ), tri2( 8, 9 ); tri1 = tri2;
the data members of the class are copied in turn. In our example, _length, _beg_pos, and _next are copied from tri2 to tri1. This is called default memberwise copy.
In the case of the Triangular class, the default memberwise copy semantics are sufficient; there is nothing we need to do explicitly. In the case of the Section 4.2 Matrix class, however, the default memberwise behavior is not adequate. The reasons for this are discussed in the Default Memberwise Initialization subsection of Section 4.2.
The Matrix class requires both a copy constructor and a copy assignment operator. Here ...
Read now
Unlock full access