C ++ Polymorphism

Source: Internet
Author: User

Polymorphism is one of the important characteristics of object orientation. It refers to the behavior of different objects when they receive the same message. A message refers to a member function of the call class. Different behaviors refer to different implementations, that is, calling different functions. c ++ supports two types of polymorphism: Polymorphism during compilation and Runtime polymorphism;

The polymorphism during compilation is inProgramThe specific objects of function operations are determined during the compilation process and implemented through function overloading. The Runtime polymorphism is that the specific objects of function operations can be determined during the running process, and implemented through virtual functions. For example
Base * P;
Derived B;
P = & B;
P-> disp ();
Because only static syntax checks are performed during compilation, the call object cannot be determined by the form of the optical sub-Statement: p-> disp.

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.