Does the override identifier after virtual destructor declaration have any special meaning?
class Base
{
public:
virtual ~Base()
{}
virtual int Method() const
{}
};
class Derived : public Base
{
public:
virtual ~Derived() override
{}
virtual int Method() override // error: marked override, but does not override - missing const
{}
};
Using override identifier on virtual method is useful as check: compiler will report error when the Base virtual method is actualy not overriden.
Does override on virtual destructor has any meaning/function too?
Yes. If the base destructor is not virtual then the
override
marking will cause the program to not compile:It is not
override
that has special meaning, but the destructor itself:10.3 Virtual Functions
If you take this in conjunction with the previous clause:
you can see that if a destructor is marked
override
but the base class does not have avirtual
destructor, the program is ill-formed.