Same function name with different parameters/signatures.
It is compile time polymorphism.
It occurs in a same class methods.
It is a static/compile time binding.
For e.g:
int sample()
{
cout<<"no arguments function";
}
int sample(int a)
{
cout<<"one arguments function";
}
int sample(double a)
{
cout<<"arguments type changed";
}
int sample(int a, double b){
{
cout<<"two arguments function";
}
Overriding :
Same function name with same parameters/signatures.
It is runtime time polymorphism.
It occurs between super and sub class methods.
It is a dynamic/ run time binding.
For e.g:
class Base
{
public:
void show()
{
cout << "Base class";
}
};
class Derived:public Base
{
public:
void show()
{
cout << "Derived Class";
}
}
1 Comment(s)