IT
IT Tools
Handy online tools for developers
Cheatsheets
Search tools
⌘K
EN
All quizzes
C++
Core
Multiple choice
A.
It returns a reference to a local variable, which is destroyed when the function returns — using it is undefined behavior.
B.
It is fine; C++ extends the lifetime of x to match the returned reference.
C.
It will not compile because you cannot return a reference to an int.
D.
It always returns 0 because x is reset on return.
Submit
Open the cheat sheet
Previous
Next