Polymorphism
Polymorphism
Polymorphism allows the same code to be used with different types, resulting in more general and abstract implementations. A function that can evaluate to and be applied to values of different types is known as a polymorphic function. Similarly, a datatype that contains elements of an unspecified type is known as a polymorphic datatype.
There are two fundamentally different kinds of polymorphism:
1. Ad-hoc polymorphism.
2. Parametric polymorphism.
Ad-hoc polymorphism is a simple overloading. Overloading allows multiple functions with the same name processing different types of data.
In parametric polymorphism a function or a data type is written in such a way that it can process equally any objects without depending on its type.
Posted in Computer Science, Information Technology, Object Oriented Programming, Object Oriented Programming |
