AUTOSAR C++14 Rule A10-3-3
Virtual functions shall not be introduced in a final class
Description
Rule Definition
Virtual functions shall not be introduced in a final class.
Rationale
Declaring a function as virtual indicates that you intend to override
the function in a derived class with a different implementation. The same function can then
interact differently with different classes of a hierarchy. When you explicitly specify a
class as final, you cannot derive a class from it. Because you cannot
derive classes from a final class, do not introduce virtual functions in
a final class. Specify all virtual functions in a
final class by using the specifier final.
Polyspace Implementation
Polyspace® flags the declaration of virtual functions in a final
class. Polyspace does not flag virtual functions in a final class that uses the specifiers
override final or virtual final.
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 |