Function Overloading in C++
Function overloading is a feature of object oriented programming where two or more functions can have the same name but different parameters.
When a function name is overloaded with different jobs it is called Function Overloading.
In Function Overloading “Function” name should be the same and the arguments should be different.
Function overloading can be considered as an example of polymorphism feature in C++.
Following is a simple C++ example to demonstrate function overloading.
Here is int 10 Here is float 10.1 Here is char* ten
How Function Overloading works?
- Exact match:- (Function name and Parameter)
- If a not exact match is found:–
->Char, Unsigned char, and short are promoted to an int.
->Float is promoted to double
- If no match found:
->C++ tries to find a match through the standard conversion.
- ELSE ERROR 🙁
- Function overloading and return type
- Functions that cannot be overloaded in C++
- Function overloading and const keyword
- Function Overloading vs Function Overriding in C++
Recent articles on function overloading in C++
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.