Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Diffrence between Overloading and Overriding (http://www.go4expert.com/forums/diffrence-overloading-overriding-t3514/)

dshivhare 21Mar2007 14:23

Diffrence between Overloading and Overriding
 
Hello :)

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

Thanks in Advance......
Deepak

vinayak Bhat 21Mar2007 15:38

Re: Diffrence between Overloading and Overriding
 
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 21Mar2007 15:59

Re: Diffrence between Overloading and Overriding
 
Can you explain me with an example ??

shabbir 21Mar2007 16:08

Re: Diffrence between Overloading and Overriding
 
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 22Mar2007 11:32

Re: Diffrence between Overloading and Overriding
 
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 22Mar2007 16:23

Re: Diffrence between Overloading and Overriding
 
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.


All times are GMT +5.5. The time now is 09:25.