Skip to main content

Polymorphism: Run-time

 Polymorphism has two different types:

  1. Compile-Time polymorphism
  2. Run-Time polymorphism

 Let's start with an instance of running code:


 Run-time polymorphism takes place using Function-overriding. When derived class has definition for one of the member functions of base class. That function will be called overridden. In the above instance we can see Add() function which is a virtual function  overriden  function. I declared base class pointer (holding derived class's object address in it)in main function so this is enough to understand run-time polymorphism.

Comments