Synopsis: | Initialize all data members of built-in types |
Language: | C++ |
Severity Level: | 1 |
Category: | Object Life Cycle |
Description: |
Data members of user-defined types that have a default constructor need not be explicitly initialized. Built-in types have default constructors, but these do nothing. So, take care to properly initialize data-members of built-in types. Pointers to built-in types and pointers to user defined types must also be initialized, because they behave like built-in types. Note that data member initialization occurs in the constructor's initialization list, rather than assignments in the constructor's body. Only when it is not possible to properly initialize a data member, one should assign a value in the constructor's body. |