Thread: l-value,r-value

  1. #1
    Unregistered
    Guest

    l-value,r-value

    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!

  2. #2
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    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?)

  3. #3
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    oops,

    i mean you can't have a constant as an l-value

    (figures out which hand is right, which hand is left)

    yeah

  4. #4
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    Posts
    176
    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

Popular pages Recent additions subscribe to a feed