Function overloading: Difference between revisions

Content deleted Content added
Languages supporting overloading: Sorted list alphabetically
Tags: Mobile edit Mobile web edit Advanced mobile edit
m linking
Line 63:
 
==Constructor overloading==
[[Constructor (object-oriented programming)|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. Whenever multiple constructors are needed, they are to be implemented as overloaded functions. In [[C++]], [[default constructorsconstructor]]s take no parameters, instantiating the object [[Instance variable|members]] with their appropriate default values. For example, a default constructor for a restaurant bill object written in C++ might set the tip to 15%:
 
<syntaxhighlight lang=Cpp>