What is the purpose of a pure virtual function in C++?
- To provide default functionality
- To force derived classes to provide an implementation
- To enhance runtime performance
- To prevent method overloading
A pure virtual function in C++ is declared using "= 0" and doesn't have an implementation in the base class. It's a way to ensure that derived classes provide their own implementation of the function, effectively making the base class abstract. This ensures a consistent interface.
Loading...
Related Quiz
- When a class contains a pointer to memory allocated in class, we should define a _______.
- A template that takes another template as a parameter is known as a _______.
- When a function is called recursively, each call creates a new set of the function's _______.
- In tail recursion, the recursive call is the _______ action to be performed in the function.
- Imagine you are developing a Graphic Design Application where different types of shapes are drawn. Which OOP concept will simplify the code?