![]() ![]() ![]() ![]() | A function that constructs, initializes and assigns LineSegments. | Lecture 3 - slide 15 : 36 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 - ls3 is now a copy of ls2. // Here all LineSegments ls1, ls2 and ls3 refer to the same Point array // because the Point pointers are just copied in the // initialization and the assignment shown above. // Destructors called for ls1, ls2, ls3 on exit from h. // Trouble for the two last destructions. } int main(){ h(); }