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)