Which keyword is used in C++ to make a function virtual?
- static
- const
- virtual
- override
The keyword virtual is used in C++ to make a function virtual. When a function is declared as virtual, it can be overridden in any derived class. This allows for dynamic polymorphism, where the decision on which method version to execute is made at runtime based on the object's actual type.
Loading...
Related Quiz
- Which of the following data types is not a primitive data type in C++?
- The shared_ptr in C++ uses _______ counting to manage the memory of shared objects.
- How does friendship relation in C++ affect inheritance hierarchies, if at all?
- How does a range-based for loop work in C++11 and above?
- What is a potential risk of using recursion?