Diffrence between Overloading and Overriding

Go4Expert Member
21Mar2007,14:23   #1
dshivhare's Avatar
Hello

Can any body tell me what is the difference between Overloading and Overriding in C++ ??

Thanks in Advance......
Deepak
Light Poster
21Mar2007,15:38   #2
vinayak Bhat's Avatar
overloading is giving an operator meaning which is needed for us i mean the operator can do the job as we want if we overload
but overriding is giving some diffrent meaning in to a function which specified in parent process in inheritance
Go4Expert Member
21Mar2007,15:59   #3
dshivhare's Avatar
Can you explain me with an example ??
Go4Expert Founder
21Mar2007,16:08   #4
shabbir's Avatar
Quote:
Originally Posted by vinayak Bhat
overloading is giving an operator meaning which is needed for us i mean the operator can do the job as we want if we overload
Thats what you are saying about operator overloading.

I dont see any similarity.

Allows the creation of several functions with the same name which differ from each other in terms of the type of the input and the type of the output of the function.

Overriding, is a feature that allows a subclass to provide a specific implementation of a method that is already provided by one of its superclasses. The implementation in the subclass overrides (replaces) the implementation in the superclass.
Light Poster
22Mar2007,11:32   #5
tom_ge's Avatar
To add on to shabbir...overloading is the process of giving a particular operator another meaning.
For eg. while using cout << "hello world";
Here "<<" does not have its actual meaning but is an output operator.This is a form or compile time polymorphism.

The use of virtual functions is an example for overriding of functions in the subclasses.A form of run time polymorphism.
Team Leader
22Mar2007,16:23   #6
DaWei's Avatar
A virtual function in the base class does not override the derived function if the derived function exists, unless the call is ambiguous. A pure virtual function requires overriding in the derived class.

An overloaded operator may give the operator another meaning (as in output versus shift), or it may have the same meaning (add, say) with the operation merely modified. Adding integers is not done in the same way as adding (concatenating) strings.

Last edited by DaWei; 22Mar2007 at 16:26..