Re: Legality of a++ = 1 ?
XeCycle <XeCycle@Gmail.com> writes:
> Russell Shaw <rjshawN_o@s_pam.netspace.net.au> writes:
>
>> Hi,
>> I read ISO/IEC 9899:201x, section 6.5.2.4 Postfix increment and
>> decrement operators.
>>
>> Why couldn't the semantics of this be: "a" is assigned "1", then
>> "a" is incremented?
>>
>> gcc gives error: lvalue required as left operand of assignment
>
> (a=1)++ may work.
This remark confused me until I saw:
> If you don't like this, overload the operators "=" and "++" for
> a, if that's an object of your class.
You are talking about C++, but the question was about C. This is, after
all, comp.lang.c.
--
Ben.
|