//隐式类型转换导致重载函数产生二义性
//当用数字作为参数时,又于数字本身没有类型的,此时将发什么隐式类型转换,这就造成了混乱。
//如下代码说明问题:
#include <iostream>
using namespace std;bool output(int x)
{
cout << "x is int: " << x << endl;
return true;
}
bool output(float x)
{
cout << "x is float: "<< x << endl;
return true;
}
int main()
{
//output(0.5); //将产生编译错误,数字本身没有类型,当用数字作为参数时,将发什么隐式类型转换
int a = 1;
float b = 1.5;
float c = 3;
output(a);
output(b);
output(c);
}