Computing.Net > Forums > Programming > overload override

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

overload override

Reply to Message Icon

Name: kora
Date: October 28, 2003 at 00:33:40 Pacific
OS: win32
CPU/Ram: 512
Comment:

Are method overloading and overriding same thing? If not, what is the difference?
Does this concept apply to any programming language?



Sponsored Link
Ads by Google

Response Number 1
Name: Sumanth Sharma
Date: October 28, 2003 at 06:34:32 Pacific
Reply:

No, they are not same.

Consider a method add().

1. Overloading - When a method is overloaded it necessarily means that it is another method.

ex: add( a, b );
and
add( a, e, f );

where a, b are integers, while e and f are real numbers.

As soon as the compiler comes across these function call, it is able to resolve the two different function calls,

here add( integer, integer );
and add( integer, real, real );

are two difserent functions( methods ) with different function definitions in the code segment.

2. Coming to Overriding, you are calling the same method in different contexts.

say you have a data type which can take a generic value

add( generic_data_type, generic_data_type );

Now when add is called with add( 12, 20 );

The compiler resolves this to be
add( integer, integer ); at Runtime and not at compile time.

so in case of method overriding the compiler cannot place the function definition. It can only do so at run-time, this funda is called late-binding or dynamic binding.

B'coz the arguments cannot be binded to any data-type during compile time.

This the sample of Overriding and overloading funda.


===============================
A real world example

Your name is Kora .L. ( here L is u'r initials ).


Consider other names like
Kora R. Y
Kora M
etc.

Here Kora L, Kora R Y, Kora M are different individuals, Kora is the only thing in common.

We can easily resolve this. - This is called function OVERLOADING.

But consider yourself being called as
Kora by your old classmates.
Mike by your Collegues
Sweet Heart by your beloved.

Now You the same person is referred to by different versions in different contexts, this is function OVERRIDING.

-GOOD LUCK


0
Reply to Message Icon

Related Posts

See More


Allegro problem Access to Foxpro Accessin...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: overload override

help with insering rows in ADO.NET www.computing.net/answers/programming/help-with-insering-rows-in-adonet/13370.html

VB.NET buttons change properties? www.computing.net/answers/programming/vbnet-buttons-change-properties/11605.html

Difference Overloading Overiding.. www.computing.net/answers/programming/difference-overloading-overiding/7993.html