Namespaces
Variants
Views
Actions

Talk:cpp/language/override

From cppreference.com

[edit] virtual and override

Do we want the functions in the derived class to have both "virtual" and "override"? It's true that only virtual functions can be marked as override, but I don't think that means that the presence of the "override" keyword means you have to also have "virtual" in the same declaration -- you could inherit "virtual" implicitly from a base class declaration. --Nate (talk) 15:15, 6 February 2014 (PST)

This page needs some work regardless, but I agree that a derived class that uses the override keyword doesn't need the virtual keyword - it's enforced by the former. In fact, it's better not to use it in this case, to catch the error of signature mismatch with the parent (when you thought you were overriding a virtual, but in fact declared an all-new virtual) --Cubbi (talk) 15:21, 6 February 2014 (PST)