G
George2
Hello everyone,
I am reading some code from other people, there are some code like
this,
I want to confirm with you that it is not good code, since we return a
reference to local object instance, right? Even if the code has
expected function currently.
thanks in advance,
George
I am reading some code from other people, there are some code like
this,
Code:
class Foo {
};
Foo& func()
{
Foo foo;
return foo;
}
int main()
{
Foo& foo = func();
return 0;
}
I want to confirm with you that it is not good code, since we return a
reference to local object instance, right? Even if the code has
expected function currently.
thanks in advance,
George