1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. What problem does the C++ override keyword on a derived…

Added 30 Nov -0001

What problem does the C++ override keyword on a derived member function solve?

  1. It allows overriding functions declared final
  2. It makes a signature mismatch a compile-time error Correct answer
  3. It forces the function to be inlined at call sites
  4. It makes the base function non-virtual at run time

Correct answer

B. It makes a signature mismatch a compile-time error

14 views

MCQSEXAM

Explanation

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.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C++ and Object-Oriented Programming MCQs

Practise all C++ and Object-Oriented Programming MCQs

Similar MCQs