You mix expressions with values.
1) The lifetime of the temporary value returned by the expression f(1)
will be extended for life. This rule is unique to const
links.
2) Anywhere, the compiler wants, but probably on the stack.
3) Maybe. It depends on whether the compiler copied x
or performed a copy operation. Since the type is int
, it does not matter.
4) A lot of differences. One of them is the name of a local variable inside int f(int)
. This is an lvalue. Another is an expression that calls int f(int)
and evaluates the value of r.
source share