Early Binding and Late Binding
Early Binding and Late Binding
of a sub Class into the Pointer Object of Base Class, then the Member Functions Are never to
be Override. When we execute the Program then Compiler knows this thing. This is called as
Early Binding. And the Compiler will Execute the Member Functions of Base Class and this will
never overrides the Body of the Sub Class Member Function. This is known as the early
binding.
Example
#include<iostream>
class Base {
public:
void display() {
}
};
public:
void display() {
}
};
int main(void) {
base_pointer->display();
return 0;
Late Binding: In the Late Binding the Compiler never knows About the Code. Means what the
Code will do. All the Code is understood at the Time of Execution This is called as Late Binding.
As we Know that Late Binding is Performed By using the virtual Functions. Virtual Means
Function must be Override. When the Compiler Finds out the Word Virtual at the time of
Execution then this will override the Body of the Function of Base Class with the Function of sub
Class. When we pass the Reference of the Sub Class into the Pointer Object of the Base Class
then the Body of the First Function will be Override by the Sub Class Because the Base Class
Member Function is declared with the virtual keyword and the virtual means function must be
override.
Example
#include<iostream>
class Base {
public:
}
};
public:
void display() {
}
};
int main() {
base_pointer->display();
return 0;
Summary:
The Early Binding just means that the target method is found at compile
time while in Late Binding the target method is looked up at run time.
Most script languages use late binding, and compiled languages use
early binding.
Method overloading happens in the same class shares the same method name
but each method should have different number of parameters or parameters
having different types and order. But in method overriding derived class have the
same method with same name and exactly the same number and type of
parameters and same return type as a parent class.
In method Overloading, two or more methods shares the same name in the same
class but having different signature while in method overriding, method of parent
class is re-defined in the inherited class having same signature.
Static methods can be overloaded, that means a class can have more than one
static method of same name. But static methods cannot be overridden, even if
you declare a same static method in derived class, it has nothing to do with the
same method of base class.