13

POLYMORPHISM: A REVIEW

13.1 POLYMORPHISM

We have already introduced ourselves with ‘polymorphism’ in Section 5.1 wherein it was defined as an entity or object having two or more forms. In object-oriented programming (OOP), functions and operators can be overloaded to achieve polymorphic behaviour.

Polymorphic functions have one name with different implementations. If the functions belong to different classes then a message (say ‘close’) can be interpreted differently by different objects resulting in different responses as shown in Fig. 13.1.

Figure 13.1

Figure 13.1 Polymorphic behaviour of objects

13.2 TAXONOMY OF POLYMORPHISM

Cardelli and Wegner gave ...

Get Object-Oriented Programming with C++ 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.