How can I initialize a member variable of a POD (Plain Old Data) in C++11?
class A { public: int theAnswer; // this is not initialized }; static_assert(std::is_pod<A>::value, "A must be a plain old object"); class B { public: int theAnswer { 42 }; // this should initialize to 42 }; static_assert(std::is_pod<B>::value, "B must be a plain old object"); // ERROR class C { public: C() : theAnswer { 42 } { } // Obviously, this is not a trivial default constructor, so it does not work int theAnswer; }; static_assert(std::is_pod<C>::value, "C must be a plain old object"); // ERROR