L-value 和 R-value.

时间:2023-03-09 19:27:53
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:

 a = b + ;

'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:

 int a[];
a[b + ] = ;

  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.