You got lucky. Returning from the function doesn’t immediately wipe the stack frame you just exited.
BTW, how did you confirm that you got a 6 back? The expression std::cout << &i ... prints the address of i, not its value.
You got lucky. Returning from the function doesn’t immediately wipe the stack frame you just exited.
BTW, how did you confirm that you got a 6 back? The expression std::cout << &i ... prints the address of i, not its value.