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

point-lineseg.h
Class LineSegment WITH a copy constructor and and WITH an assignment operator.
point-lineseg.cc
The corresponding cc file with implementations of the copy constructor and the assignment operator.
prog.cc
A function that constructs, initializes and assigns LineSegments.
program-output
Program execution.

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