It relates to the concept of lvalue and rvalue.
In C++, pre-increment produces lvalue which can be modified . ( but
because of absence of sequence point in the twice modification of
variable val, the result is undefined.)
In C , pre-increment does not produce lvalue so it can't be
modified ,hence the error.

On Jun 20, 4:06 pm, Shachindra A C <[email protected]> wrote:
> As far as I understand, this has got nothing to do with references and pls
> ignore my earlier post.
>
> On Mon, Jun 20, 2011 at 4:31 PM, Shachindra A C <[email protected]>wrote:
>
>
>
> > I didnt execute your code...but i think having a look at the assembly code
> > produced could give a good insight into the actual working.
>
> > On Mon, Jun 20, 2011 at 4:26 PM, himanshu kansal <
> > [email protected]> wrote:
>
> >> int val;
> >> int *p=&val;
>
> >> why does (++val)++ gives err in c bt nt in c++.....
> >> i knw dt abv expression wd produce undefined results bt i just want to
> >> knw why its nt giving the err in c++....
>
> >> 2nd ques is whn ++val++ is invalid thn why ++*p++ is valid....
>
> >> does it hv something to do wd references....??
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.
>
> > --
> > Regards,
> > Shachindra A C
>
> --
> Regards,
> Shachindra A C

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to