程序1-1:
int abc(int a, int b, int c)
{
return a + b * c;
}
程序1-2:
float abc(float a, float b, float c)
{
return a + b * c;
}
1)cout << abc(1, 2, 3) << endl;
调用了第一个abc(int , int, int);
2)cout << abc(1.0F, 2.0F, 3.0F) << endl;
调用了第二个abc(float, float, float);
3)cout << abc(1, 2, 3.0F) << endl;
这是错误的,因为没有相应的函数重载abc(int, int, float);
4)cout << abc(1.0, 2.0, 3.0) << endl;
调用了第二个,自动类型转换abc(float, float, float);
P.s:书上用的是endln,我不太清楚是什么意思,所以我用了endl
**仅给有需要的人以参考,如有错误请纠正我**