Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Class Point with non-member operators.Lecture 3 - slide 36 : 36
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&);