// Member function definitions for Point and LineSegment - notice the LineSegment destructor. #include #include #include #include "point-lineseg.h" Point::Point(double x_coord, double y_coord): x(x_coord), y(y_coord){ } Point::Point(): x(0.0), y(0.0){ } double Point::getx () const{ return x; } double Point::gety () const{ return y; } void Point::move(double dx, double dy){ x += dx; y += dy; } double Point::distance_to(Point p) const{ return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y)); } LineSegment::LineSegment(size_t s) : number_of_points{s}, points{new Point[s]} { std::cout << "LineSegment Constructor" << std::endl; } LineSegment::~LineSegment(){ delete[]points; std::cout << "LineSegment Destructor" << std::flush << std::endl; } std::ostream& operator<<(std::ostream& s, const Point& p){ return s << "(" << p.getx() << "," << p.gety() << ")" ; }