高洛峰2017-04-17 14:44:24
The f function returns a reference to a, and a is a global variable with a fixed address, so this reference can be used as an lvalue, that is, it can be assigned a value.
This is a very tricky method, but it is not recommended. , because sometimes the variables you reference are defined very early, which is difficult for people who read this code to understand.
伊谢尔伦2017-04-17 14:44:24
When an object is used as an rvalue, its content (value) is used. When it is used as an lvalue, its address is used.
Here the variable a is a global variable, and the function f returns a reference to a.
天蓬老师2017-04-17 14:44:24
Function f returns a reference to a, which is equivalent to directly assigning a value to a