Lecture 4 - Slide 20 : 40 |
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
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 4ed §17.5.1 page 507-508