C++11 allows in-class initialization of non-static and non-const members. What changed?
问题 Before C++11, we could only perform in-class initialization on static const members of integral or enumeration type. Stroustrup discusses this in his C++ FAQ, giving the following example: class Y { const int c3 = 7; // error: not static static int c4 = 7; // error: not const static const float c5 = 7; // error: not integral }; And the following reasoning: So why do these inconvenient restrictions exist? A class is typically declared in a header file and a header file is typically included