Lecture 4 - Slide 19 : 40 |
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
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