in-class initializers
In-class initializers make it a lot easier to define the constructors. Additionally, you can not forget to initialize a member.
class X { // BAD
int i;
string s;
int j;
public:
X() :i{666}, s{"qqq"} { } // j is uninitialized
X(int ii) :i{ii} {} // s is "" and j is uninitialized
// ...
};
class X2 {
int i {666};
string s {"qqq"};
int j {0};
public:
X2() = default; // all members are initialized to their defaults
X2(int ii) :i{ii} {} // s and j initialized to their defaults (1)
// ...
};
While the in-class initialization establishes the default behavior of an object, the constructor (1) allows the variation of the default behavior.