Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          static-members/alternative/point.h - A variant of class Point with static member function for the defaultPoint.Lecture 4 - slide 25 : 40
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&);