C + + polymorphism (i)

Source: Internet
Author: User

There are many questions about polymorphism in interview topics, such as overloading, virtual functions (Overrides), Polymorphism concepts , and so on, here is a comb, including the following:

Definition of polymorphism

(i) definition

The ability to present different patterns of characteristics or states.

(ii) two types of polymorphism

1. Compile-time polymorphism : When compiling the system, it finds the function in the function call instruction table that corresponds to multiple overloaded functions , and binds them to the code that invokes them in the main program, in case the main program is run correctly.

2. Runtime polymorphism: Compile the system to compile, according to the contents of the program code, according to the Virtual function Address table in the address of the this pointer, find the corresponding virtual function (overwrite), it and the main program called its code to be linked.

Second, function overloading (overloading)

1. Overloading of common functions

2. Overloading of constructors

3. Operator (function) overloading

Iii. conversion between a predefined type and a custom type Iv. basic concepts of dynamic linking-virtual functions five, pure virtual functions (purely virtual function) and abstract classes

C + + polymorphism (i)

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.