C++ Polymorphism
The word 'Polymorphism' originated from the Greek word. Poly means "Many" and morphism means "Form". Polymorphism means Many Forms.
Single action is performed by different ways i.e., known as the polymorphism.
There are 4 pillars in oops. They are an inheritance, polymorphism, abstraction, and encapsulation.

Binding
The process of combining a member function with the object is known as Binding.
Early Binding
The function overloading and operator overloading are the compile-time polymorphism which is known as the Static binding or Early binding. By default, C++ follows early binding.
Late Binding
The method or function overriding is the run-time polymorphism which is known as the Late binding or Dynamic binding.
Example:
#include <iostream>
using namespace std;
class A // base class
{
public:
void show(){
cout << "Base class Function" << endl;
}
};
class B: public A
{
public:
void show(){
cout << "Derived class Function" << endl;
}
};
int main() {
A a;
A *a1;
a1=new B;
a.show(); // Early Binding or Static binding
a1->show(); // Late Binding or Dynamic Binding
return 0;
}
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.