The problem of return reference to local variable
- by skydoor
I happened to find this code return 5. It's OK to write it this way or should definitely be avoid?
int& f() {
int i = 5;
return i;
}
int main(){
cout<<f()<<endl;
}