Types of Polymorphism

 Following are two types of Polymorphism in C++ :

1. Compile time Polymorphism

2. Run time Polymorphism


Compile time polymorphism

Run time polymorphism

The function to be invoked is known at the compile time.

The function to be invoked is known at the run time.

It is also known as overloading, early binding and static binding.

It is also known as overriding, Dynamic binding and late binding.

Overloading is a compile time polymorphism where more than one method is having the same name but with the different number of parameters or the type of the parameters.

Overriding is a run time polymorphism where more than one method is having the same name, number of parameters and the type of the parameters.

It is achieved by function overloading and operator overloading.

It is achieved by virtual functions and pointers.

It provides fast execution as it is known at the compile time.

It provides slow execution as it is known at the run time.

No comments:

Post a Comment