overloading is nothing but the method signature varies from class to class with same name,where in overriding method name and signature does not rloading is compile time polymorphism where as overriding is dynamic or run-time polymorphism.
من قبل
Athanassios Staveris-Polykalas , Secretary General of Telecommunications and Post - Hellenic Republic , General Secretariat of Telecommunications and Post - Hellenic Republic
hi
i think giving an example might make it easier:
overloading:
two or more functions have the same name but take as input different parameters:
void myFunction(int i);
void myFunction(string a);
void myFunction(float b);
Function myFunction() is overloaded
overriding
you give different meaning in functions with the same name:
class A: //base class
{
public virtual void C( ) {//do something A }
}
class B:A //derived class
{
public override void C( ) {//do something B}
}
hope the above helps a bit
You overload a function name f by declaring more than one function with the name f in the same scope. The declarations of f must differ from each other by the types and/or the number of arguments in the argument list.
Overriding - When a function of base class is re-defined in
the derived eg.
base class
{
area(float a,float b);
}
derive class
{
float area();
}