首页 > 代码库 > L-value 和 R-value.
L-value 和 R-value.
An L-value is something that can appear on the left side of an equal sign, An R-value is something that can appear on the right side of an equal sign.
for example:
1 a = b + 25;
‘a‘ is an L-value because it identifies a place where a result can be stored.
‘b + 25‘ is an R-value because it designates a value.
It sounds as though variable may be used as L-value but expressions may not, but this statement is not quite accurate,for example:
1 int a[3];2 a[b + 1] = 0;
Subscripting is in fact an operator so the construct on the left is an expression, yet it is a legitimate L-value because it identifies a specific location that we can refer to later in the program.
Some operators, like indirection and subscripting, produce an L-value as a result.