AUTOSAR C++14 Rule A10-2-1
Non-virtual public or protected member functions shall not be redefined in derived classes
Description
Rule Definition
Non-virtual public or protected member functions shall not be redefined in derived classes.
Rationale
When a nonvirtual public or protected member function is redefined in a derived class, the new definition in the derived class hides the definition in the base class instead of overriding it. When functions are hidden in the derived class, you cannot implement a common interface to handle different classes of the same hierarchy, resulting in unnecessary complexity and error. Such behavior might be unexpected and lead to bugs that are difficult to resolve.
Redefinitions of functions from private inheritance or functions that are private in the base class are not affected by this rule.
Polyspace Implementation
Polyspace® flags redefinitions of non-virtual member functions in a derived class. Polyspace does not raise this defect on destructors.
To justify a redefinition that you deem as acceptable, use annotations. See Annotate Code and Hide Known or Acceptable Results
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Derived Classes |
Category: Required, Automated |
Version History
Introduced in R2019a