#include<iostream>
using namespace std;
void test(float a)
{
cout<<"test float\n";
}
void test(int a)
{
cout<<"test int\n";
}
int main()
{
test(1);
test(0.5);
return 0;
}
这个程序是由错的,原因在于test(0.5)中的0.5默认为double类型,除非在后面加上f,或者把前面的void test(float a)改成void test(double a)就可以编译通过并运行了