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

point-lineseg.h
Class LineSegment WITHOUT copy constructor and and WITHOUT assignment operator.
point-lineseg.cc
The corresponding cc file - not particularly relevant.
prog.cc
A function that constructs, initializes and assigns LineSegments.
program-output
Program execution.

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