How it works...

Non-static data members are supposed to be initialized in the constructor's initializer list as shown in the following example:

    struct Point     {       double X, Y;       Point(double const x = 0.0, double const y = 0.0) : X(x), Y(y)  {}     };

Many developers, however, do not use the initializer list, but prefer assignments in the constructor's body, or even mix assignments and the initializer list. That could be for several reasons--for larger classes with many members, the constructor assignments may look easier to read than long initializer lists, perhaps split on many lines, or it could be because they are familiar with other programming languages that don't have an initializer list or because, unfortunately, for various reasons they ...

Get Modern C++: Efficient and Scalable Application Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.