Content deleted Content added
I have updated the content of method or function overloading. If anybody can give the description on this topic briefly, he or she can edit in this or contribute. For contact, Email: soumyadipmajumder03@outlook.com Tag: Reverted |
Restored revision 1105204930 by OlliverWithDoubleL (talk): Vandal edits |
||
Line 7:
{{Polymorphism}}
In some [[programming language]]s, '''function overloading''' or '''method overloading''' is the ability to create multiple [[subprogram|functions]] 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, {{mono|doTask()}} and {{nowrap|{{mono|doTask(object o)}}}} are overloaded functions. To call the latter, an [[object (computer science)|object]] must be passed as a [[parameter (computer science)|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 function, which would result in an ''ambiguous call'' error, as the [[compiler]] wouldn't know which of the two methods to use.
Another example is a {{nowrap|{{mono|Print(object o)}}}} function that executes different actions based on whether it's printing text or photos. The two different functions may be overloaded as {{nowrap|{{mono|Print(text_object T); Print(image_object P)}}.}} If we write the overloaded print functions for all objects our program will "print", we never have to worry about the type of the object, and the correct function call again, the call is always: {{mono|Print(something)}}.
==Languages supporting overloading==
|