operators/vers2/point.h - Class Point with non-member operators. | Lecture 4 - slide 40 : 40 Program 5 |
// Same example - but with non-member operator overloads. Friends are used instead. class Point { private: double x, y; public: Point(double, double); Point(); double getx () const; double gety () const; void move(double, double); double distance_to(Point) const; friend Point operator+(const Point&, const Point&); friend Point operator++(Point&, int); friend bool operator==(const Point&, const Point&); }; std::ostream& operator<<(std::ostream&, const Point&);