Learning Notes of C++ -- Revisiting Virtual Functions and Polymorphism - Unbelievable - Be more nonchalant when encountering events, and be a bit more vague in dealing with the world...sink

by stilling2006 on 2009-09-22 17:35:13

Since reading *Effective C++*, I have increasingly felt that I should relearn C++. But I will start by picking up fragmented knowledge and move forward slowly.

**Polymorphism**

Refers to the different implementation actions produced when the same object receives different messages or different objects receive the same message. C++ supports two types of polymorphism: compile-time polymorphism and runtime polymorphism.

a. **Compile-time polymorphism**: Achieved through function overloading.

b. **Runtime polymorphism**: Achieved through virtual functions.

A class that contains a pure virtual function is called an abstract class. Since abstract classes contain pure virtual functions that are not defined, it is not possible to define objects of an abstract class.