0 votes
in C Plus Plus by
What is Polymorphism?

1 Answer

0 votes
by

The basic idea behind polymorphism is in many forms. In C++, we have two types of Polymorphism:

(i) Compile-time Polymorphism

In compile-time polymorphism, we achieve many forms by overloading. Hence, we have an Operator overloading and function overloading. (We have already covered this above)

(ii) Run-time Polymorphism

This is the polymorphism for classes and objects. General idea is that a base class can be inherited by several classes. A base class pointer can point to its child class and a base class array can store different child class objects.

This means, that an object reacts differently to the same function call. This type of polymorphism can use a virtual function mechanism.

Related questions

0 votes
asked Jun 15, 2020 in C Plus Plus by Robindeniel
0 votes
asked Jun 15, 2020 in C Plus Plus by Robindeniel
...