TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  OLC#008

This rule is Obsolete
Synopsis:If it must be possible to instantiate a class via a default constructor, always define a default constructor which explicitly initializes data members
Severity Level:9
Category:Object Life Cycle


When a default constructor is not defined explicitly, the compiler will generate one providing that no other constructors are defined. The one generated by the compiler leaves the class data members with an undefined value. When a class is instantiated, the creator of the class must make sure the contents of the data members is defined, which can only be done when the default constructor is explicitly defined.

If a class must always be instantiated using parameterized constructors, the default constructor can be omitted. Note that when at least one parameterized constructor exists, the compiler does not generate a default constructor. As a result the class cannot be instantiated without the required parameters.