|
|
Example of copying objects: Programmed copying |
We want to modify the meaning of copying during initialization and assignment The point array of the line segment is copied by the copy constructor and by the assignment operator The following versions of the program illustrates a typical pattern for copy constructors and assignment operators |
|
Header file. |
|
The copy constructor makes a copy of of the point array The assignment deallocates the point array of the lhs (which is overwritten) and reallocates space for the points in the new copy The programs above follow the pattern from Stroustrup §10.4.4.1 page 245 |