8Polymorphism

The power of object-oriented programming lies not only in inheritance, but also in its ability to treat a derived-class object like a base-class object. It is polymorphism and dynamic binding that support this mechanism.

8.1An Overview of Polymorphism

Polymorphism means that different objects behave differently when they are given the same message. The call by member functions is the ‘message’ and different behaviors are due to different implementations, i.e., calling different functions. Polymorphism is quite often used in programming. The most common example is the math operator. We use the same plus sign “+” to implement adding operation between integers, floating numbers, and double precision floating numbers. The same message, ...

Get C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.