Virtual functions shall not be introduced in a final class
Virtual functions shall not be introduced in a final class.
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® flags the declaration of virtual functions in a final class
that are declared with these specifiers:
virtual
override
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Derived classes |
| Category: Required, Automated |