Polymorphism (computer science)

In programming language theory and type theory, polymorphism is the use of one symbol to represent multiple different types.[1]

In object-oriented programming, polymorphism is the provision of one interface to entities of different data types.[2] The concept is borrowed from a principle in biology where an organism or species can have many different forms or stages.[3]

The most commonly recognized major forms of polymorphism are:

  • Ad hoc polymorphism: defines a common interface for an arbitrary set of individually specified types.
  • Parametric polymorphism: not specifying concrete types and instead use abstract symbols that can substitute for any type.
  • Subtyping (also called subtype polymorphism or inclusion polymorphism): when a name denotes instances of many different classes related by some common superclass.[4]
  1. ^ Cardelli, Luca; Wegner, Peter (December 1985). "On understanding types, data abstraction, and polymorphism" (PDF). ACM Computing Surveys. 17 (4): 471–523. CiteSeerX 10.1.1.117.695. doi:10.1145/6041.6042. S2CID 2921816.: "Polymorphic types are types whose operations are applicable to values of more than one type."
  2. ^ Stroustrup, Bjarne (February 19, 2007). "Bjarne Stroustrup's C++ Glossary". polymorphism – providing a single interface to entities of different types.
  3. ^ "Polymorphism". The Java Tutorials: Learning the Java Language: Interfaces and Inheritance. Oracle. Retrieved 2021-09-08.
  4. ^ Conallen, J.; Engle, M.; Houston, K.; Maksimchuk, R.; Young, B.; Booch, G. (2007). Object-Oriented Analysis and Design with Applications (3rd ed.). Pearson Education. ISBN 9780132797443.