#ifndef POINT_H #define POINT_H #include //for class ostream #include //for the sqrt function using namespace std; template class point; //forward declaration for a template class template ostream& operator<<(ostream& ost, const point& p); template bool operator==(const point& p1, const point& p2); template class point { T x; T y; public: point(T init_x, T init_y): x {init_x}, y {init_y} {} T r() const; //distance from origin friend ostream& operator<< (ostream& ost, const point& p); friend bool operator==(const point& p1, const point& p2) { return p1.x == p2.x && p1.y == p2.y; } }; template inline bool operator!=(const point& p1, const point& p2) { return !(p1 == p2); } template T point::r() const { return sqrt(x*x + y*y); } template ostream& operator<<(ostream& ost, const point& p) { return ost << "(" << p.x << ", " << p.y << ")"; } #endif