must class member initialization lists in c++ be complete? or can they simply initialize one or two of the member data in a class?
thanks in advance!
must class member initialization lists in c++ be complete? or can they simply initialize one or two of the member data in a class?
thanks in advance!
They don't have to be complete. You can leave out base classes and non-POD class types that are default constructible, POD-types however will be left uninitialized.
Obviously constant members and references have to be initialized in the member initialization list.
No, they don't have to be complete - any members which aren't specified in it will be default-constructed (this includes any base classes).
Obviously, any members which aren't default-constructible must be explicitly initialised. And a small gotcha - types like integers or floats etc will not be initialised, so their initial value will be undefined.