关于重载函数有个不知道的地方
c++吧
全部回复
仅看楼主
level 1
qq8394908 楼主
void demo(int i){cout<<"普通函数的重载,接收了一个整数:"<<i<<endl;}
void demo(float i,float b){cout<<"普通函数的重载,接受了两个小数"<<i<<"\t"<<b<<endl;}
void demo(char a='1',char b='2',char c='3')
{
cout<<"接收三个字符型,如缺省参数,则为默认值:"<<a<<"\t"<<b<<"\t"<<c<<endl;
}
void main()
{
demo(15);
demo(1.23,4.56);
demo('7','8','9');
}
结果是 提示错误 对重载函数的调用不明确
我测试后发现字符型居然可以接收小数型,那怎么强制他接收指定类型呢?
2013年07月04日 03点07分 1
1