I have a function like this
const string &SomeClass::Foo(int Value)
{
if (Value < 0 or Value > 10)
return "";
else
return SomeClass::StaticMember[i];
}
I get warning: returning reference to temporary
. Why is that? I thought the both values the function returns (reference to const char* "" and reference to a static member) cannot be temporary.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…