Examine individual changes
This page allows you to examine the variables generated by the Edit Filter for an individual change.
Variables generated for this change
Variable | Value |
---|---|
Name of the user account (user_name ) | '202.91.89.58' |
Page ID (page_id ) | 418572 |
Page namespace (page_namespace ) | 0 |
Page title without namespace (page_title ) | 'Function overloading' |
Full page title (page_prefixedtitle ) | 'Function overloading' |
Action (action ) | 'edit' |
Edit summary/reason (summary ) | '/* Constructor overloading */ ' |
Whether or not the edit is marked as minor (no longer in use) (minor_edit ) | false |
Old page wikitext, before the edit (old_wikitext ) | '{{Unreferenced|date=June 2008}}
'''Function overloading''' or '''method overloading''' is a feature found in various [[programming language]]s such as [[Ada (programming language)|Ada]], [[C Sharp (programming language)|C#]],[[Visual Basic .net (programming language)|VB.Net]], [[C++]], [[D (programming language)|D]] and [[Java (programming language)|Java]] that allows the creation of several [[subprogram|method]]s 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.
For example, ''doTask()'' and ''doTask(object O)'' are overloaded methods. To call the latter, an [[Object (computer science)|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 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)''. If we write the overloaded print methods for all objects our program will "print", we never have to worry about the type of the object, and the correct [[subroutine|function]] call again, the call is always: ''Print(something)''.
Method overloading is usually associated with [[static typing|statically-typed]] programming languages which enforce [[type checking]] in [[function call]]s. When overloading a method, you are really just making a number of different methods that happen to have the same name. It is resolved at [[compile time]] which of these methods are used.
Method overloading should not be confused with [[virtual function]]s, where the correct method is chosen at runtime.{{Fact|reason=http://www.haskell.org/haskellwiki/Ad-hoc_polymorphism|date=December 2008}}
==Constructor overloading==
Constructors, used to create instances of an object, may also be overloaded in some [[object oriented]] [[programming language]]s. Because in many languages the constructor’s name is predetermined by the name of the class, it would seem that there can be only one constructor. A default constructor usually takes no parameters, setting the object's [[Instance variable|members]] to certain values. For example, a default constructor for a restaurant bill object written in [[C%2B%2B|C++]] might set the Tip to 15%:
<source lang ="cpp">
Bill()
{ tip = 15.0, total = 0.0 }
</source>
The drawback to this is that it takes two steps to change the value of the created Bill object. The following shows creation and changing the values within the main program:
<source lang ="cpp">
Bill cafe;
cafe.tip = 10.00;
cafe.total = 4.00;
</source>
By overloading the constructor, one could pass the tip and total as parameters at creation. This shows the overloaded constructor with two parameters:
<source lang ="cpp">
Bill(double setTip, double setTotal)
{ tip = setTip, total = setTotal }
</source>
Now a function that creates a new Bill object could pass two values into the constructor and set the data members in one step. The following shows creation and setting the values:
<source lang ="cpp">
Bill cafe(10.00, 4.00);
</source>
This can be useful in increasing program efficiency and reducing code length.
==Caveats==
If a method is designed with an excessive number of overloads, it may be difficult for developers to discern which overload is being called simply by reading the code. This is particularly true if some of the overloaded parameters are of types that are inherited types of other possible parameters (for example "object").
==See also==
*[[Factory method pattern]]
*[[Object-oriented programming]]
*[[Constructor (computer science)|Constructor]]
*[[Abstraction (computer science)|Abstraction]]
*[[Dynamic dispatch]]
*[[Method overriding]]
*[[Operator overloading]]
*[[Method signature]]
== External links ==
* Bertrand Meyer: Overloading vs Object Technology, in Journal of Object-Oriented Programming (JOOP), vol. 14, no. 4, October-November 2001, available [http://se.ethz.ch/~meyer/publications/joop/overloading.pdf online]
[[Category:Method (computer science)]]
[[es:Sobrecarga]]
[[ja:多重定義]]
[[pt:Sobrecarga]]
[[ru:Перегрузка процедур и функций]]' |
New page wikitext, after the edit (new_wikitext ) | '{{Unreferenced|date=June 2008}}
'''Function overloading''' or '''method overloading''' is a feature found in various [[programming language]]s such as [[Ada (programming language)|Ada]], [[C Sharp (programming language)|C#]],[[Visual Basic .net (programming language)|VB.Net]], [[C++]], [[D (programming language)|D]] and [[Java (programming language)|Java]] that allows the creation of several [[subprogram|method]]s 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.
For example, ''doTask()'' and ''doTask(object O)'' are overloaded methods. To call the latter, an [[Object (computer science)|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 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)''. If we write the overloaded print methods for all objects our program will "print", we never have to worry about the type of the object, and the correct [[subroutine|function]] call again, the call is always: ''Print(something)''.
Method overloading is usually associated with [[static typing|statically-typed]] programming languages which enforce [[type checking]] in [[function call]]s. When overloading a method, you are really just making a number of different methods that happen to have the same name. It is resolved at [[compile time]] which of these methods are used.
Method overloading should not be confused with [[virtual function]]s, where the correct method is chosen at runtime.{{Fact|reason=http://www.haskell.org/haskellwiki/Ad-hoc_polymorphism|date=December 2008}}
==Constructor overloading==
Constructors, used to create instances of an object, may also be overloaded in some [[object oriented]] [[programming language]]s. Because in many languages the constructor’s name is predetermined by the name of the class, it would seem that there can be only one constructor. A default constructor usually takes no parameters, setting the object's [[Instance variable|members]] to certain values. For example, a default constructor for a restaurant bill object written in [[C%2B%2B|C++]] might set the Tip to 15%:
<source lang ="cpp">
Bill()
{ tip = 15.0, total = 0.0 }
</source>
The drawback to this is that it takes two steps to change the value of the created Bill object. The following shows creation and changing the values within the main program:
<source lang ="cpp">
Bill cafe;
cafe.tip = 10.00;
cafe.total = 4.00;
</source>
By overloading the constructor, one could pass the tip and total as parameters at creation. This shows the overloaded constructor with two parameters:
<source lang ="cpp">
Bill(double setTip, double setTotal)
{ tip = setTip, total = setTotal }
</source>
Now a function that creates a new Bill object could pass two values into the constructor and set the data members in one step. The following shows creation and setting the values:
<source lang ="cpp">
Bill cafe(10.00, 4.00);
</source>
This can be useful in increasing program efficiency and reducing code length.
shashikant chachundar hai.........
==Caveats==
If a method is designed with an excessive number of overloads, it may be difficult for developers to discern which overload is being called simply by reading the code. This is particularly true if some of the overloaded parameters are of types that are inherited types of other possible parameters (for example "object").
==See also==
*[[Factory method pattern]]
*[[Object-oriented programming]]
*[[Constructor (computer science)|Constructor]]
*[[Abstraction (computer science)|Abstraction]]
*[[Dynamic dispatch]]
*[[Method overriding]]
*[[Operator overloading]]
*[[Method signature]]
== External links ==
* Bertrand Meyer: Overloading vs Object Technology, in Journal of Object-Oriented Programming (JOOP), vol. 14, no. 4, October-November 2001, available [http://se.ethz.ch/~meyer/publications/joop/overloading.pdf online]
[[Category:Method (computer science)]]
[[es:Sobrecarga]]
[[ja:多重定義]]
[[pt:Sobrecarga]]
[[ru:Перегрузка процедур и функций]]' |
Whether or not the change was made through a Tor exit node (tor_exit_node ) | 0 |
Unix timestamp of change (timestamp ) | 1290572727 |