Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can any body tell me in detail that what is the difference between Function Overloading & Function Overriding in C Language.
Thnaks in advance..

These are both concepts of OOP and inheritence in particular.
Function overloading is about convenience in a strongly typed language (C/C++). Obviously your functions have defined data types associated with them. Well, sometimes you want to have the same function with different data types. So rather than name different functions (which share the same process, only have different data types), you name one function and provide it different data types. Also, the number of arguments can be changed. This all simplifies programming.
This explains it:
http://cplus.about.com/library/weekly/aa061602a.htmA method is a function, which carries with it data types. A base is the root or parent class. A derived class is also referred to as a subclass.
Overriding a function comes into play when you have a base class and a derived class. You can call this a class and subclass. The subclass can call a new function, with an old name, to override the parent's function (which is said to have been shadowed), adding a new method and data type(s). This saves you from adding new methods and data types at the root of logical structures. Obiviously not every subclass may need that particular method and data type (or perhaps most use the original method), so rather than add it to the parent (thus casting it on the whole tree, unless you choose to forbid inheritance), you override the parent's original function with a new method and new data type, just for that subclass of course.
http://itm.blackpool.ac.uk/computing/Course_Webs/Bsc_Computing/oop/Inheritance/abstract_inher.html

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |