试图弄清楚为什么在以下代码中没有引起过载 - 模糊:
float foo2(float& i)
{
cout << "call from reference" << endl;
return i;
}
float foo2(float i)
{
cout << "call from non reference"<<endl;
return i;
}
int main()
{
cout<<foo2(2); // print "call from non reference"
}
Run Code Online (Sandbox Code Playgroud)
调用参数未通过引用传递的foo2.为什么?如何调用传递引用参数的foo2?