To achieve runtime polymorphism in C++, _______ are used.
- classes
- macros
- virtual functions
- inline functions
Runtime polymorphism in C++ is achieved through the use of virtual functions. These are functions in the base class that you can override in derived classes. The decision about which method to call (the one in the base class or the one in the derived class) is made at runtime, based on the actual type of the object being pointed to, rather than the type of the pointer. This allows for more dynamic behavior and is a core feature of object-oriented programming in C++.
Loading...
Related Quiz
- Which of the following C++ versions introduced the auto keyword for automatic type deduction?
- In a financial application, you are processing transaction data in a loop. When a fraudulent transaction is detected, it needs to be logged and then the processing needs to continue with the next transaction. How would the continue statement be utilized effectively in this scenario?
- A tail-recursive function often can be rewritten iteratively using a _______.
- In a complex software project where multiple classes are interacting with one another, you discover that there is a significant performance bottleneck during the creation and deletion of objects, which is causing inefficiency. What strategy or principle might be applied to manage object creation and deletion more efficiently?
- What is the significance of the "default" case in a switch-case statement?