Content deleted Content added
HHWhitePony (talk | contribs) m Minor edits to last |
→Overloading Methods: Disambiguation link repair - You can help! |
||
Line 6:
A common error would be to assign a default value to the object in the second method, this would result in an ''ambiguous call'' error, as the compiler wouldn't know wich of the two methods to use.
Another example would be a ''Print(object O)'' method. In this case we would like the method to be different when printing, for example, text and different for pictures. We write the two different methods as overloaded: ''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)''.
==Overloading Operators ==
|