How many types of polymorphisms are supported by C++?
2022
How many types of polymorphisms are supported by C++?
- A.
1
- B.
2
- C.
3
- D.
4
Attempted by 297 students.
Show answer & explanation
Correct answer: B
C++ supports two main types of polymorphism:
1. Compile-time (static) polymorphism: The function or operation to be executed is decided during compilation. Examples include function overloading, operator overloading, and templates.
2. Run-time (dynamic) polymorphism: The function to be executed is decided during program execution. This is achieved using inheritance and virtual functions.
Therefore, the correct answer is 2.