<<< Inheritance and Polymorphism | Index | Virtual functions >>> |
Steps to implement run-time polymorphism in C++:
Use inheritance, deriving classes from some common base type.
Redefine common functions in derived types.
Construct objects of the specific derived types.
Maintain these objects via pointers or references to the common base type.
Call common member functions on these pointers or references.
C++ will redirect your calls to the real types of objects.
<<< Inheritance and Polymorphism | Index | Virtual functions >>> |