Relational Operators

What exactly is the relationship between these “not” and “or” operators? Is there an “and” operator, and is it useful here? Isn't this excessively complex? Not if you approach it carefully.

First, let's recap the simple bool expression in a little more detail. Remember that a bool expression can be true or false. There are six bool relational operators, used to compare values. Like +, they are infix operators, so they have an operand to the left and an operand to the right. Table 10.1 shows their names, symbols, examples of their use, and the example values.

Table 10.1. The Relational Operators
Name Operator Sample Value
Equal to == 100 == 50; 50 == 50; false true
Not equal to != 100 != 50; 50 != 50; true false
Greater than ...

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.