in C Plus Plus by

What is Polymorphism? How is it supported by C++?

1 Answer

0 votes
by

Polymorphism means that some code or operations or objects behave differently in different contexts. In C++,  following features support polymorphism.

Compile Time Polymorphism: Compile time polymorphism means compiler knows which function should be called when a polymorphic call is made.  C++ supports compiler time polymorphism by supporting features like templates, function overloading and default arguments.

Run Time Polymorphism: Run time polymorphism is supported by virtual functionsThe idea is, virtual functions are called according to the type of object pointed or referred, not according to the type of pointer or reference. In other words, virtual functions are resolved late, at runtime.

...