I would say "compile it and see by yourself"…
, but with C++, it won't even compile. You need to declare i
as Boolean (bool
). Or, say, even int
, because Boolean is actually implemented as integer.
[EDIT]
I scratched the words about not compiling code because OP later fixed it in the text of the question. OP could compile it and see what's going on.
[END EDIT]
Here is the hint for you:
bool i = a < b < c;
will be compiled as it was
bool i = (a < b) < c;
and
a < b
is Boolean.
And now, compile and run it, see what's going on and try to explain it. It's going to be easy enough.
Surprised with the result? Then try to see what's going on step by step, using the debugger. Compare with:
bool i = (a < b) & (b < c);
Note that the real intention of the developer could be the line shown above, quite likely, so the expression shown in your question would be the result of misunderstanding. Now think why should you always avoid expressions like the one shown in your question, mixing result of comparison with numeric operand. This should be the real lesson to learn from this ridiculous example, and, in this sense, it should be useful for you.
—SA