6 March 2013

What is difference between overloading and overriding?

Overloading and Overriding both are example of polymorphism. Overriding is dynamic polymorphism while overloading is static polymorphism.
In other words, Overloading is evaluated at compile time whereas Overriding is evaluated at Run Time.
Overloading: Overloading is a mechanism by which we can have two or more different methods using same name.
Overloading can be implemented using different parameter data types, different number of parameters, and different order of parameters
Overriding: Overriding is a changing of behavior of a class in drive class using dynamic polymorphism. For example in C# you have a class A and another class B derives from A.  Class A have a virtual method abc and in class B using override you given new functionality to this method.