#include #include #include "point.h" Point Point::defaultPoint = Point(5,7); // Necessary. Linking problems if it is omitted. // Serves as initialization of the static variable member. Point::Point(double x_coord, double y_coord): x(x_coord), y(y_coord){ } Point::Point(){ // The default constructor uses the the static x = defaultPoint.x; // data member defaultPoint. y = defaultPoint.y; } 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)); } Point Point::origo(){ return Point(0,0); } void Point::setDefaultPoint(Point p){ defaultPoint.x = p.x; defaultPoint.y = p.y; } void Point::setDefaultPoint(double xcord, double ycord){ defaultPoint.x = xcord; defaultPoint.y = ycord; } std::ostream& operator<<(std::ostream& s, const Point& p){ return s << "(" << p.getx() << "," << p.gety() << ")" ; }