What problem does the C++ override keyword on a derived member function solve?
Correct answer
B. It makes a signature mismatch a compile-time error
14 views
B. It makes a signature mismatch a compile-time error
14 views
Placing override tells the compiler that the function is meant to override a base virtual, so a typo or a const mismatch that would otherwise create a silent new overload becomes a compile error. Without it, a subtly different signature hides the base version and calls still bind to the base, producing logic bugs that are hard to spot. The companion specifier final prevents further overriding of that function or class.
Asked in: NTS, PPSC IT, Campus Interviews
Not sure why the answer is B? Ask here and get an explanation.