函数重载是用来描述同名函数具有相同或者相似的功能,但数据类型或者是参数不同的函数管理操作的称呼。
#include <iostream>
using namespace std;
int test(int a,int b);
float test(float a,float b);
int main(void){
cout<<test(1,2)<<endl<<test(2.1f,3.14f)<<endl;
return 0;
}
int test(int a,int b){
return a+b;
}
float test(float a,float b){
return a+b;
}
C++内部利用一种叫做粉碎的机制来内部重命名同名函数。
来源:https://blog.csdn.net/MJ_BH/article/details/98882611