Difference between Overloading and Overriding?

Overloading: Overloading happens when two or more function have the same function name but different return type and parameter.
eg:

The overloading happens in the same class i e these function should be in the same class.
Return type, Parameter type, parameter and body of method number may be different.

Overriding: It happens in inheritance when base class has a function called “

” and the derived class also has the function “

”. In this case we can’t access the base class class function by just creating an object of derived class.
If the base class function has the keyword Virtual then it means that the function should be override and we use the keyword Override.
Return type, Parameter type, Parameter Number all must be same. Only body of method can change.

Tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.