O'Reilly logo

Object Oriented Programming with C++, Second Edition by Sunil Patekar, Mahesh Bhave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.2 COMPILE TIME POLYMORPHISM

Earlier, we have stated that polymorphism means different behaviour by different objects for the function with same name. The function can be in the base class or in the derived class. When compiler decide which function to call at the time of compilation (strictly speaking before execution of program starts), it is termed as compile time polymorphism.

We will illustrate this with Programs 13.1 and 13.2.

13.2.1 Polymorphism with ordinary1 objects

Program: Write a program to study polymorphism. Use the following specifications: Create a base class called creatures. It should have a constructor and method move to tell about how that creature moves. The data member should be a character array for storing the name of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required