Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    A variant of class Point with static member function for the defaultPoint.Lecture 3 - slide 21 : 36
Program 5
class Point {
private: 
  double x, y;
                                      // No static variable in this version
public:
  Point(double, double);
  Point();                            // Default constructor relies on defaultPoint()
  static Point& defaultPoint();       // The default point is a static member function
  double getx () const;               // ... that encapsulate a local static object 
  double gety () const;               // ... cf. Effective C++ item 4.
  void move(double, double);
  double distance_to(Point) const; 
  static Point origo();
};

std::ostream& operator<<(std::ostream&, const Point&);