2.6. Member Initialization
Each class data member is automatically initialized to the default value of its type. Numeric types, such as int and double, have a default value of 0. false is the default value of type bool. null serves as the default value of all reference types. This default initialization is carried out as part of the invocation of operator new.
If the default values are the appropriate initial member values, there is nothing additional for us to program—at least in terms of initialization. Otherwise, how we assign an alternative initial value depends on whether the class designer or class user designates what that value should be.
If the class designer is the one determining the alternative initial value, she can explicitly specify ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access