Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > lvalue with increment operators

Thread Tools

lvalue with increment operators

srinivas reddy
Posts: n/a
Assuming that x is an int, why int* p = &++x is legal and int* p =
&x++ or int* p = &(x++) is illegal.

Reply With Quote
Victor Bazarov
Posts: n/a
"srinivas reddy" <(E-Mail Removed)> 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.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
using a method as an lvalue and "invalid lvalue in assignment"compilation error C Programming 11 09-22-2008 10:42 AM
operators requiring lvalue/rvalue operands and resulting in rvalue/lvalue Kavya C Programming 9 10-28-2006 01:45 AM
Perl hangs when returning lvalue closure from another lvalue closure Julian Mehnle Perl Misc 0 07-17-2003 03:13 PM
Re: lvalue with increment operators Count Dracula C++ 1 07-13-2003 12:16 AM
Re: lvalue with increment operators Victor Bazarov C++ 0 07-08-2003 01:44 AM