Polymorphism allows the same routine (function, method) to act on different types.
Since many existing answers are conflating subtyping with polymorphism, here are three ways (including subtyping) to implement polymorphism. Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types. Subtype polymorphism allows a routine to act on any subtype of its parameters. Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.
- Parameteric (generic) polymorphism allows a routine to accept one or more type parameters, in addition to normal parameters, and runs itself on those types.
- Subtype polymorphism allows a routine to act on any subtype of its parameters.
- Ad hoc polymorphism generally uses routine overloading to grant polymorphic behavior, but can refer to other polymorphism implementations too.
See also:
http://wiki.c2.com/?CategoryPolymorphism
https://en.wikipedia.org/wiki/Polymorphism_(computer_science)