Science, Tech, Math › Computer Science Let's Examine Overloading in C/C++/C# Share Flipboard Email Print Hero Images / Getty Images Computer Science C & C++ Programming PHP Programming Perl Python Java Programming Javascript Programming Delphi Programming Ruby Programming Visual Basic View More By David Bolton David Bolton Computer Science Expert B.A., Computer Science, Queen's University Belfast David Bolton is a software developer who has worked for several major firms, including Morgan Stanley, PwC, BAE Systems, and LCH. Learn about our Editorial Process Updated on May 29, 2019 Function overloading allows functions in computer languages such as C, C++, and C# to have the same name with different parameters. Operator overloading allows operators to work in the same manner. In C#, method overloading works with two methods that accomplish the same thing but have different types or numbers of parameters. An Example of Function Overloading Rather than have a differently named function to sort each type of array, such as: You can use the same name with different parameter types as shown here: The compiler is then able to call the appropriate function depending on the parameter type. Overload resolution is the term given to the process of selecting the appropriate overload function. Operator Overloading Similar to function overloading, operator overloading allows programmers to redefine operators such as +, - and *. For example, in a class for complex numbers where each number has a real and imaginary part, overloaded operators allow code such as this to work: As long as + is overloaded for the type complex. Advantages of Overloading When Writing Code You end up with code that is easier to readOverloading is convenient and intuitiveAvoids clunky syntax Consistency in naming and notationWorks well in templates and other constructs when you don't know the variable type at the time you are writing the code. Cite this Article Format mla apa chicago Your Citation Bolton, David. "Let's Examine Overloading in C/C++/C#." ThoughtCo, Apr. 5, 2023, thoughtco.com/verloading-in-c-candand-c-958121. Bolton, David. (2023, April 5). Let's Examine Overloading in C/C++/C#. Retrieved from https://www.thoughtco.com/verloading-in-c-candand-c-958121 Bolton, David. "Let's Examine Overloading in C/C++/C#." ThoughtCo. https://www.thoughtco.com/verloading-in-c-candand-c-958121 (accessed June 9, 2023). copy citation