Polymorphism

circle-check

The most commonly recognized major classes of polymorphism are:

  1. Ad hoc polymorphismarrow-up-right: defines a common interface for an arbitrary set of individually specified types (function overloading or operator overloading).

  2. Parametric polymorphismarrow-up-right: when one or more types are not specified by name but by abstract symbols that can represent any type (templates in C++ and D, generics in C# and Java).

  3. Subtypingarrow-up-right (also called subtype polymorphism or inclusion polymorphism): when a name denotes instances of many different classes related by some common superclass. (you can pass an object to a method that takes more generic type – Liskov substitution principlearrow-up-right)

Last updated