# V2023. Absence of the 'override' specifier when overriding a virtual function may cause a mismatch of signatures.

This diagnostic rule was added at the users' request.

The rule is designed to detect all cases of overriding a base class virtual functions without using the `override` keyword.

Note N1. To search only for incorrect virtual function overrides, use the V762 diagnostic rule.

Note N2. This diagnostic rule is relevant only for C++.

Although the absence of the `override` specifier is not an error, it removes an important safety net for developers and compilers. Without it, there is no guarantee that the function signature matches the virtual function of the base class. In this case, no override occurs, which can lead to logic errors and unpredictable behavior.

Explicitly specifying `override` fixes this issue by enabling the compiler to check whether the override is correct, thereby preventing potential errors.

Let's say the following base class exists:

    class Base
    {
    public:
      virtual void one();
      virtual void two(int);
    };

The following class derives from it:

    class Derived : public Base
    {
    public:
      virtual void one();
      virtual void two(); // 'Derived::two' hides 'Base::two'
                          // there might be runtime failure
    };

This version does not use the `override` specifier, so the compiler will not issue a compilation error if the signatures of the `two` functions do not match.

The example of the fixed code that uses the `override` keyword:

    class Derived : public Base
    {
      virtual void one() override;

      virtual void two() override; // compile-time error:
                                   // 'Derived::two' doesn't override
                                   // any base class virtual functions
    };