#include <iostream>
using namespace std;
//函数重载的注意事项
//1.引用作为函数重载
void fun(int& a) //int &a=10;不合法
{
cout << "fun(int& a)调用" << endl;
}
void fun(const int& a) //const int &a=10;合法
{
cout << "fun(const int& a)调用" << endl;
}
//函数重载碰到默认参数
void fun2(int a, int b = 10)
{
cout << "fun2(int a,int b)调用" << endl;
}
void fun2(int a)
{
cout << "fun2(int a)调用" << endl;
}
int main()
{
//int a = 10;
//fun(a);//fun(int& a)调用
//fun(10);//fun(const int& a)调用
//fun2(10);//当函数重载碰到默认参数,出现二义性,报错,尽量避免这种情况
system("pause");
return 0;
}