Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Polymorphism (computer science)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Using one interface or symbol with regards to multiple different types}} {{Distinguish|Polymorphic code}} {{Polymorphism}} In [[programming language theory]] and [[type theory]], '''polymorphism''' is the use of one symbol to represent multiple different types.<ref name="Luca">{{Cite journal |last1=Cardelli |first1=Luca |author1-link=Luca Cardelli |last2=Wegner |first2=Peter |author2-link=Peter Wegner (computer scientist)|doi=10.1145/6041.6042 |title=On understanding types, data abstraction, and polymorphism |journal=[[ACM Computing Surveys]] |volume=17 |issue=4 |pages=471β523 |date=December 1985 |url=http://lucacardelli.name/Papers/OnUnderstanding.A4.pdf |citeseerx=10.1.1.117.695 |s2cid=2921816}}: "Polymorphic types are types whose operations are applicable to values of more than one type."</ref> In [[object-oriented programming]], polymorphism is the provision of one [[Interface (object-oriented programming)|interface]] to entities of different [[data type]]s.<ref>{{cite web |url=http://www.stroustrup.com/glossary.html#Gpolymorphism |last1=Stroustrup |first1=Bjarne |author1-link=Bjarne Stroustrup |title=Bjarne Stroustrup's C++ Glossary |date=February 19, 2007 |quote=polymorphism β providing a single interface to entities of different types.}}</ref> The concept is borrowed from a principle in [[biology]] where an organism or species can have many different forms or stages.<ref name="Moved">{{cite web |title=Polymorphism |work=The Java Tutorials: Learning the Java Language: Interfaces and Inheritance |publisher=Oracle |url=https://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html |access-date=2021-09-08}}</ref> 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.<ref name="gbooch">{{cite book |last1=Conallen |first1=J. |last2=Engle |first2=M. |last3=Houston |first3=K. |last4=Maksimchuk |first4=R. |last5=Young |first5=B. |last6=Booch |first6=G. |author6-link=Grady Booch |date=2007 |title=Object-Oriented Analysis and Design with Applications |publisher=Pearson Education |edition=3rd |isbn=9780132797443 |pages=}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)