lvalue with increment operators

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • srinivas reddy

    lvalue with increment operators

    Assuming that x is an int, why int* p = &++x is legal and int* p =
    &x++ or int* p = &(x++) is illegal.

    tia,
    Srinivas
  • Victor Bazarov

    #2
    Re: lvalue with increment operators

    "srinivas reddy" <srinivasreddy_ m@yahoo.com> wrote...[color=blue]
    > Assuming that x is an int, why int* p = &++x is legal and int* p =
    > &x++ or int* p = &(x++) is illegal.[/color]

    'x++' does not return an lvalue. You cannot take address of
    something that is not an lvalue. '++x' returns 'x' after it
    has been incremented. And in this case 'x' is an lvalue.

    Victor


    Comment

    Working...