Afficher un message
Vieux 22/02/2008, 22h00   #11
Andrey Tarasevich
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: x = 0; x += ++x + x++; x == 4?

James Kanze wrote:
> ...
>> Yes, but the original question was not about the "behavior", but about
>> the "result". While the OP didn't specify what exactly he meant by
>> "result" (probably the result of 'x == 4' expression), for many natural
>> interpretations of the term it is possible to come up with operator
>> definitions, which will produce a well defined "result" even though the
>> overall "behavior" is not specified.

>
> It's possible,


That's exactly what I said. It is possible.

> but anyone who overloads the given operators with
> definitions so that such a result is guaranteed should be hung
> and shot.


Considering that this discussion is centered around what essentially is
a basic C++ _puzzle_, not a piece of real-life code, the above statement
is utterly irrelevant.

> With any reasonable overloading of the operators (for
> a user defined type for which such operators would make sense),
> the result is unspecified.


This statement is based on some undefinable ideas of what "reasonable".
I'm pretty sure one can come up with a "reasonable" overload with
perfectly specified results, although I don't see the point.

--
Best regards,
Andrey Tarasevich
  Réponse avec citation
 
Page generated in 0,04817 seconds with 9 queries