This article is from the Object-Oriented Technology FAQ, by Bob Hathaway email@example.com with numerous contributions by others.
Polymorphism is a ubiquitous concept in object-oriented programming and is
defined in many ways, so many definitions are presented from: Websters',
Author, Strachey, Cardelli and Wegner, Booch, Meyer, Stroustrup, and Rumbaugh.
Polymorphism is often considered the most powerful facility of an OOPL.
> Webster's New World Dictionary:
Polymorphism 1. State or condition of being polymorphous. 2. Cryall.
crystallization into 2 or more chemically identical but
crystallographically distinct forms. 3. Zool., Bot. existence of an
animal or plant in several forms or color varieties.
polymorphous adj. having, assuming, or passing through many or various forms,
stages, or the like. Also, polymorphic. [<Gk polymorphous multiform]
> Author's Definition:
Polymorphism is the ability of an object (or reference) to assume (be replaced
by) or become many different forms of object. Inheritance (or delegation)
specifies slightly different or additional structure or behavior for an object,
and these more specific or additional attributes of an object of a base class
(or type) when assuming or becoming an object of a derived class characterizes
object-oriented polymorphism. This is a special case of parametric
polymorphism, which allows an object (or reference) to assume or become any
object (possibly satisfying some implicit or explicit type constraints
(parametric type), or a common structure), with this common structure being
provided by base classes or types (subclass and subtype polymorphism,
"Poly" means "many" and "morph" means "form". The homograph polymorphism has
many uses in the sciences, all referring to objects that can take on or assume
many different forms. Computer Science refers to Strachey's original
definitions of polymorphism, as divided into two major forms, parametric and
ad-hoc. Cardelli and Wegner followup with another classification scheme,
adding inclusion polymorphism for subtyping and inheritance.
> Strachey's Original Definition [Strachey 67]:
"Parametric polymorphism is obtained when a function works uniformly on a range
of types; these types normally exhibit some common structure. Ad-hoc
polymorphism is obtained when a function works, or appears to work, on several
different types (which may not exhibit a common structure) and may behave in
unrelated ways for each type."
Parametric polymorphism is also referred to as "true" polymorphism, whereas
ad-hoc polymorphism isn't (apparent polymorphism).