In C++, what is the effect of declaring a member function as final?

Options

  • A. It forces the function to be overloaded
  • B. It prevents further overriding of the virtual function
  • C. It makes the function private
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. It prevents further overriding of the virtual function

Detailed Explanation

Answer: It prevents further overriding of the virtual function

The final specifier can be used with a virtual function to prevent derived classes from overriding that function again.

For example, if a derived class declares a virtual function as final, a further derived class cannot override that function.