Polymorphic (polymorphism)

Source: Internet
Author: User

C + + multi-state concept a little messy, there is time on Wikipedia search for the next related terms, summarized as follows:

Polymorphism (computer science)


In programming language and type theory, polymorphism (Greek, meaning many shape) refers to a single interface that corresponds to more than one type of entity. As a polymorphic type, its operation (operation) can also be provided to other types of value. There are several completely different types of polymorphism.

1.Ad hoc polymorphism: Functions can specify different implementations depending on the parameter type (depending on a limited range of individually specified types and combinations.).

is actually a function overload (functions overloading)

2.Parametric polymorphism: The encoding can not specify any particular type, and the type is determined when it is instantiated as a parameter. In object-oriented programming, it is called generic programming, and in functional programming, it is referred to as polymorphism.

In C + + is the template.

3.Subtyping: name specifies instances of different subclasses of a common superclass. In object-oriented programming, it is often referred to as polymorphism.

In C + + it is virtual function (virtual functions).

To summarize, the so-called polymorphic means that an interface (interface) corresponds to different types of entities. Generalized polymorphism, divided into three types, namely ad hoc (the same name function, parameter types), PARAMETIRC (run-time derivation of the actual type), Subtyping (subclass inherits the same name from the superclass interface, implementation of different behaviors), respectively, corresponding to the function in C + + Overloading, Template, and virtual function. In C + +, the so-called polymorphic, corresponding to the subtyping, through the virtual function of the way to achieve.

Reference Links:

1. Https://en.wikipedia.org/wiki/Polymorphism_ (computer_science)

2. Https://en.wikipedia.org/wiki/Ad_hoc_polymorphism

3. Https://en.wikipedia.org/wiki/Parametric_polymorphism

4. https://en.wikipedia.org/wiki/Subtyping

Polymorphic (polymorphism)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.