diff --git a/README.md b/README.md index c1a4b90..28650b1 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ C++11 includes the following new language features: - [converting constructors](#converting-constructors) - [explicit conversion functions](#explicit-conversion-functions) - [inline-namespaces](#inline-namespaces) +- [non-static data member initializers](#non-static-data-member-initializers) C++11 includes the following new library features: - [std::move](#stdmove) @@ -1015,6 +1016,23 @@ int oldVersion {Program::Version1::getVersion()}; // Uses getVersion() from Vers bool firstVersion {Program::isFirstVersion()}; // Does not compile when Version2 is added ``` +### Non-static data member initializers +Allows non-static data members to be initialized where they are declared, potentially cleaning up constructors of default initializations. + +```c++ +// Default initialization prior to C++11 +class Human { + Human() : age(0) {} + private: + unsigned age; +}; +// Default initialization on C++11 +class Human { + private: + unsigned age = 0; +}; +``` + ## C++11 Library Features ### std::move