Diffrence between Overloading and Overriding

dshivhare's Avatar, Join Date: Mar 2007
Go4Expert Member
Hello

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

Thanks in Advance......
Deepak
vinayak Bhat's Avatar, Join Date: Mar 2007
Light Poster
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
dshivhare's Avatar, Join Date: Mar 2007
Go4Expert Member
Can you explain me with an example ??
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.
tom_ge's Avatar
Light Poster
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.
DaWei's Avatar, Join Date: Dec 2006
Team Leader
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..