我有两个重载函数,如下所示:
void print(int i) { ... }
void print(float f) { ... }
我对 print(1.2);
显示以下错误:
error: call of overloaded 'print(double)' is ambiguous
有人能解释一下为什么吗?
我有两个重载函数,如下所示:
void print(int i) { ... }
void print(float f) { ... }
我对 print(1.2);
显示以下错误:
error: call of overloaded 'print(double)' is ambiguous
有人能解释一下为什么吗?
double->int
和double->float
是同样有效的。其中一个可能比另一个更好,但这不是作出的决定。 - chrisprint(1.2f);
- zdf