Counting a loop

You may wonder why your original statement compiles. Here is how C++ interprets it:

if( 50 < (pos < 130))

Then it evaluates the innermost parentheses: (pos < 130). Let's say that this statement is true. So that evaluates to the boolean value "true". C++ allows you to use boolean values as numerical values and vice versa. Boolean "true", when treated as a number, evaluates to 1.

So what happens when we get to the next set of parentheses: (50 < (true)). Since the less-than operator requires a number, the boolean value "true" is converted to the numerical value 1. The expression (50 < 1) evaluates to false and the if() statement does not enter.

As you can see, in C++ just because code compiles doesn't mean it is doing what you want.