If the override specifier is added to the end of a member function declaration, what happens if the function is not specified as virtual in the parent class?
a. The function is overridden in the derived class.
b. There is a compiler error.
c. The function in the parent class will always be invoked.
b
Explanation: The override specifier is optional. It tells the programmer which functions are being overridden. However, even without the override specifier, a function in the derived class will override the corresponding function in the parent class as long as the function in the parent class is marked virtual. However, if the virtual keyword is missing from the function in the parent class, then we cannot override it. Adding the override specifier in this case results in a compile time error. override is available in C++11 and later versions of C++.
Computer Science & Information Technology