reference to overload function
时间: 2023-07-07 17:36:21 浏览: 43
Function overloading is a feature in programming that allows multiple functions to have the same name but different parameters. This means that you can have two or more functions with the same name in a program, as long as they have different parameters.
For example, consider a program that needs to calculate the area of different shapes. We can define multiple functions with the same name "area", but with different parameters to handle each shape:
```
int area(int side); // calculates area of a square
float area(float radius); // calculates area of a circle
int area(int length, int width); // calculates area of a rectangle
```
In this example, we have three different functions with the same name "area", but each takes different parameters. The compiler determines which function to call based on the arguments passed at the time of function call.
Function overloading is a powerful feature that makes code more readable, modular, and easy to maintain.