假设有2个函数
void hello(float x)
{ cout<<x*x;}
void hello (double x)
{cout<<x*x;}
如果函数调用是:hello(5.0); 将调用哪个函数?
最佳答案
双。
float 以 f
后缀结尾,如 5.0f
。 5.0
是双数。
关于c++ - 编译器如何区分重载中的 float 和 double 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48717811/