Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC++2023-13.3.1 (C++ only)

In this section:
Synopsis

(Required) User-declared member functions shall use the virtual, override and final specifiers appropriately

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

A non static member function shall either use no specifier or the virtual specifier if it is not overriding a base class member. If it overrides a base member it shall use the final or override specifier.

Coding standards

This check does not correspond to any coding standard rules.

Code examples

The following code example fails the check and will give a warning:

class A {
public:
  virtual int f() final { return 42; };  // 'virtual' and 'final'
};

The following code example passes the check and will not give a warning about this issue:

class A {
public:
  int f() { return 42; };
};