Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          classes/point5/point5.h - Class Point - with in-class initializations.Lecture 4 - slide 2 : 40
Program 5

// Illustration of in-class initializers (C++11) - a minor extension in C++11

class Point {
private: 
  // Data members have in-class initializers - not allowed in C++ before C++11
  double x {1.1},              // overridden by constructors
         y {2.1},              // overridden by constructors
         scaling_factor {2};   // common initialization accross constructors

public:
  Point(double, double);
  Point();
  double getx () const;
  double gety () const;
  void move(double, double);
  double distance_to(Point) const;
};

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