, undefined, - 5.
void f(int& x)
, int&
, , .
, undefined :
int& f() {
int x = 5;
return x;
}
int main() {
std::cout << f() << std::endl;
}
This behavior is undefined, since links do not take responsibility for maintaining the distributed data to which they refer, the link simply changes and reads the values โโif they are valid. Therefore, after completion, the f()
link will point to invalid memory.
source
share