What is polymorphism in C++?
Polymorphism is the ability to use an operator or function in different ways. Polymorphism gives different meanings or functions to the operators or functions. Poly, referring to many, signifies the many uses of these operators and functions. A single function usage or an operator functioning in many ways can be called polymorphism.
types of polymorphism
The run-time polymorphism is implemented with inheritance and virtual functions.
The compile-time polymorphism is implemented with templates.
If the range of actual types that can be used is finite and the combinations must be individually specified prior to use, this is called ad-hoc polymorphism.
If all code is written without mention of any specific type and thus can be used transparently with any number of new types it is called parametric polymorphism.