polymorphism and its types

by gowtham 2010-02-15 10:20:23

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. Polymorphism refers to codes, operations or objects that behave differently in different contexts.

Types of Polymorphism:

C++ provides three different types of polymorphism.

* Virtual functions
* Function name overloading
* Operator overloading

In addition to the above three types of polymorphism, there exist other kinds of polymorphism:

* run-time
* compile-time
* ad-hoc polymorphism
* parametric polymorphism

Other types of polymorphism defined:

run-time:

The run-time polymorphism is implemented with inheritance and virtual functions.

compile-time:

The compile-time polymorphism is implemented with templates.

ad-hoc polymorphism:

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.

parametric 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.

Tagged in:

2521
like
1
dislike
0
mail
flag

You must LOGIN to add comments