注意事项!
避免与带有默认的函数进行重载,实例化对象的时候,调用此函数时候会产生错误
void show(int a = 10)
{
cout << "有默认参数" << endl;
}
void show()
{
cout << "没有参数" << endl;
}
下面运行代码都是可以发生重载的
#include <iostream>
using namespace std;
void show(int &a)
{
cout << "INT" << endl;
}
void show(const int &a)//不用考虑返回值,只需要关心参数皆可
{
}
void show(const int a)//参数如果是int a,不能与const int a发生重载
{
}
void show(float fa)
{
cout << "Float" << endl;
}
void show(int a,float fa)
{
cout << "Int And Float" << endl;
}
int main(int argc, const char *argv[])
{
return 0;
}