According to Wikipedia, in this example:
struct Base {
virtual void some_func(float);
};
struct Derived : Base {
virtual void some_func(float) override;
};
I thought override was not a C++ keyword, so what does it really mean?
We can achieve the same thing without that keyword so why would anyone need it?
There is also the keyword final which does not yet work on VS2010 :
struct Base1 final { };
struct Derived1 : Base1 { }; // ill-formed because the class Base1
// has been marked final
In C++11,
overrideandfinalare “identifiers with special meaning”. They are not keywords and only acquire special meaning if used in a specific context (when declaring virtual functions).The idea is to enable to compiler to catch certain types of errors by allowing the programmer to explicitly state their intent (e.g. to override an existing virtual function rather than create a new one).
Here is the relevant quote from the standard, with examples: