C and C++


LANG.TYPE.MI.PBC : Multiple Inheritance with Public Base Class

Summary

A class inherits from multiple base classes, and publicly inherits at least one class that is not an interface.

A class C is considered an interface class if either of the following is true.

See also:

Properties

Class Name Multiple Inheritance with Public Base Class
Significance style
Mnemonic LANG.TYPE.MI.PBC
Categories
CWE CWE:1055 Multiple Inheritance from Concrete Classes
JSF++ JSF++:88 Multiple inheritance shall only be allowed in the following restricted form: n interfaces plus m private implementations, plus at most one protected implementation.
Availability Available for C++ only (not C).
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Multiple Inheritance with Public Base Class"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

class base0 {};

class base1 {};

class derA : public base0, public base1 {}; // 'Multiple Inheritance with Public Base Class'
                                            // warning issued here

class derB: public base0 {};                                   // not multiple inheritance

class derC: private base0, private base1 {};                   // not public

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.