I just stumbled over a use case of the override specifier that, as far as I can tell, seems redundant and also without any particular semantics meaning,
I'm not a big fan of override
, but, assuming it's something that you find useful in general, then, yes, putting override
on a virtual function that overrides a pure virtual functions is useful. Consider this rather contrived example:
struct Base {
virtual void f() = 0;
};
struct Derived : Base {
virtual void f();
virtual void f(int);
};
Now suppose that the maintainer of Base
(perhaps even your future self) changes Base
to look like this:
struct Base {
virtual void f(int) = 0;
};
Now the behavior of Derived
has quietly changed. With override
the compiler would report an error.