Binding temporary to a lvalue reference

后端 未结 5 1499
清酒与你
清酒与你 2020-12-06 12:15

I have the following code

string three()
{
    return \"three\";
}

void mutate(string& ref)
{
}

int main()
{
    mutate(three()); 
    return 0;
}
         


        
5条回答
  •  抹茶落季
    2020-12-06 12:24

    It used to compile in VC6 compiler, so I guess to maintain backward comptibility VS2008 is supporting this non-standard extension. Try with /Za (disable language extension) flag, you should get an error then.

提交回复
热议问题