View Single Post
Old 03-16-2017, 12:03 AM   #9
sonvi.belani
Registered User
 
Join Date: Jan 2017
Location: Ahmedabad
Posts: 95
Hi,

In some programming languages, function overloading or method overloading is the ability to create
multiple methods of the same name with different implementations. Calls to an overloaded function will
run a specific implementation of that function appropriate to the context of the call, allowing one
function call to perform different tasks depending on context.

For example, doTask() and doTask(object O) are overloaded methods. To call the latter, an object must
be passed as a parameter, whereas the former does not require a parameter, and is called with an empty
parameter field. A common error would be to assign a default value to the object in the second method,
which would result in an ambiguous call error, as the compiler wouldn't know which of the two methods
to use.

Another appropriate example would be a Print(object O) method. In this case one might like the method
to be different when printing, for example, text or pictures. The two different methods may be overloaded
as Print(text_object T); Print(image_object P).

Thanks
__________________
Sonvi Belani
Ecommerce Website Developer

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
sonvi.belani is offline   Reply With Quote