lvalue with increment operators

Discussion in 'C++' started by srinivas reddy, Jul 7, 2003.

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

    tia,
    Srinivas
     
    srinivas reddy, Jul 7, 2003
    #1
    1. Advertising

  2. "srinivas reddy" <> wrote...
    > Assuming that x is an int, why int* p = &++x is legal and int* p =
    > &x++ or int* p = &(x++) is illegal.


    '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
     
    Victor Bazarov, Jul 7, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Bazarov

    Re: lvalue with increment operators

    Victor Bazarov, Jul 8, 2003, in forum: C++
    Replies:
    0
    Views:
    411
    Victor Bazarov
    Jul 8, 2003
  2. Count Dracula

    Re: lvalue with increment operators

    Count Dracula, Jul 13, 2003, in forum: C++
    Replies:
    1
    Views:
    377
    Victor Bazarov
    Jul 13, 2003
  3. Kavya
    Replies:
    9
    Views:
    513
    Dik T. Winter
    Oct 28, 2006
  4. Replies:
    11
    Views:
    698
    James Kuyper
    Sep 22, 2008
  5. Julian Mehnle
    Replies:
    0
    Views:
    239
    Julian Mehnle
    Jul 17, 2003
Loading...

Share This Page