Non-static data members

Non-static data members are declared in a member specification of a class.

# Notes

Feature-test macro Value Std Feature __cpp_nsdmi 200809L (C++11) Non-static data member initializers __cpp_aggregate_nsdmi 201304L (C++14) Aggregate classes with default member initializers

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 80C++98all data members cannot have the same nameas the name of the class (breaks C compatibility)allow non-static data membersshare the class name if there isno user-declared constructor
CWG 190C++98when determining layout compatibility,all members were consideredonly consider non-static data members
CWG 613C++98unevaluated uses of non-static data members not allowedsuch uses are allowed
CWG 645C++98it was unspecified whether bit-field andnon-bit-field members are layout compatiblenot layout compatible
CWG 1397C++11class was regarded as completein the default member initializersdefault member init cannot triggerdefinition of default constructor
CWG 1425C++98it was unclear whether a standard-layout objectshares the same address with the first non-staticdata member or the first base class subobjectnon-static data memberif present, otherwise baseclass subobject if present
CWG 1696C++98reference members could be initialized to temporaries(whose lifetime would end at the end of constructor)such init is ill-formed
CWG 1719C++98differently cv-qualified types weren’t layout-compatiblecv-quals ignored, spec improved
CWG 2254C++11pointer to standard-layout class with no datamembers can be reinterpret_cast to its first base classcan be reinterpret_castto any of its base classes
CWG 2583C++11common initial sequence did notconsider alignment requirementsconsidered
CWG 2759C++20common initial sequence could includemembers declared [[no_unique_address]]they are not included

# See also