can someone just tell me wut l-value and r-value are
and the rule related to them
i have checked the msdn,but still dont understand!
can someone just tell me wut l-value and r-value are
and the rule related to them
i have checked the msdn,but still dont understand!
consider this:
myVariable = (myFunction()) + 3;
everything to the right of the = sign is r-value
everything to the left is l-value
you can't have a constant as an r-value
which means you can't do htis:
"this is a String Constant" = myFunction();
(i think hits is right?)
oops,
i mean you can't have a constant as an l-value
(figures out which hand is right, which hand is left)
yeah
http://msdn.microsoft.com/library/de...xpressions.asp
Basically, l-values are on the left side of an expression and r-values are on the right side of an expression. For example:
int x;
x = 42;
x is the l-value and 42 is the r-value. The key here is that the l-value may be modified and as such it must be capable of being modified. x is a variable and can be changed, therefore it is a l-value.
int x;
42 = x;
This is not a valid expression because 42 is not a l-value; it is constant and cannot be changed.
'l-value' and 'r-value' really are just terms for what is common sense.
fletch
"Logic is the art of going wrong with confidence."
Morris Kline