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

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

Since reading *Effective C++*, I've increasingly felt that I should relearn C++. But I'll start by piecing together fragmented knowledge and gradually move forward.

**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 containing 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.