我这样fun重载竟然报错了。。改成double就行,但是float就不行!什么鬼??
#include"iostream" using namespace std; void fun(int x = 1,int y = 2,int z = 3); void fun(float x,float y); int main() { fun(0.9,0.1); system("pause"); return 0; } void fun(int x,int y,int z) { cout <<x<<','<<y<<','<<z<<endl; } void fun(float x,float y) { cout<<x<<','<<y<<endl; }
error C2668: 'fun' : ambiguous call to overloaded function
could be 'void fun(float,float)'
or 'void fun(int,int,int)'