Polymorphism in C++

Polymorphism

Polymorphism means that ‘one name, multiple forms‘. It can be broadly classified into two categories:

  • Compile-time Polymorphism
  • Run-time Polymorphism

Compile-time Polymorphism

Compile-time polymorphism means that an object is bound to its function call at the compile time. So, it is also called early binding or static binding or static linking.

Example:

 

Output:
Car is moving
Bike is moving

Run-time Polymorphism

Run-time Polymorphism means that an object is bound to its function call at the run time. It defers the linking of a function call to a particular class at run-time. So it is called late binding or Dynamic binding or Dynamic linking.