Quick A: This is not a valid statement.
Recently on SO:
Is (4 > y > 1) a valid statement in C++? How do you evaluate it if so?
The statement (4 > y > 1) is parsed as this:
((4 > y) > 1)The comparison operators < and > evaluate left-to-right.
The 4 > y returns either 0 or 1 depending on if it's true or not.
Then the result is compared to 1.
In this case, since 0 or 1 is never more than 1, the whole statement will always return false.
Add a Comment
Comments are closed.