|
|
Example of copying objects: Default copying |
Motivates the need for copy constructors and assignment overloading in C++ The starting point is automatic variables of class type (value semantics) Class LineSegment has a pointer to the first Point in an array |
|
Header file. |
The problem is that the first destruction of a LineSegment object destructs (deallocates) the shared Point array in the free store The two next destructions encounter dangling references The program is improved on the next slide |