copying-objects/vers2/prog.cc - A function that constructs, initializes and assigns LineSegments. | Lecture 4 - slide 20 : 40 Program 3 |
#include <iostream> #include "point-lineseg.h" using namespace std; void h(){ LineSegment ls1, // LineSegment(10) constructed ls2 = ls1, // copy initialization ls3; // LineSegment(10) constructed ls3 = ls2; // copy assignment // All LineSegments refer to different Point arrays. // Destructors called for ls1, ls2, ls3: // Now OK. } int main(){ h(); }