R
romerun
Hello,
This make me very confusing:
----------------------------------
int &kkk() {
int a = 5;
return a;
}
int main() {
int b = kkk();
}
----------------------------------
"b" should be undefined as many articles say. However, I have tested
in g++ and Visual C++, the result of b is 5 !?
I guess g++ and Visual C++ choose to implement the "undefined" state
in this case as trying to get the value of the reference to local
variable thereby making "b" has the expected result
I'm I wrong ?
This make me very confusing:
----------------------------------
int &kkk() {
int a = 5;
return a;
}
int main() {
int b = kkk();
}
----------------------------------
"b" should be undefined as many articles say. However, I have tested
in g++ and Visual C++, the result of b is 5 !?
I guess g++ and Visual C++ choose to implement the "undefined" state
in this case as trying to get the value of the reference to local
variable thereby making "b" has the expected result
I'm I wrong ?