C++: Relational Operators
This C++ tutorial teaches about the use and syntax of relational operators. Relational operators are operators, which compare two values and tell the relationship with respect to the operator. As we showed in the video lesson, the syntax for the relational operators is somewhat different in C++ because there is no key for some of the operator symbols.
We will use relational operators frequently in the coming lessons. For example, we might program a videogame and need to determine whether a score is high enough to make it into the hall of fame. Otherwise, we might check to see if the player's score has earned him a new ship of life. Additionally, relational operators will play heavily in controlling the execution of programs.
It is assumed that the reader has some familiarity with these relationships from mathematics courses. Otherwise, you may want to brush up on some mathematics. We will probably be adding more mathematics videos as we get more into game programming, graphics, and neural networks.
Relational operators are all binary operators, which take two arguments and evaluate to a bool value. These operators will typically be used on ints and doubles for numerical ordering and on chars for alphabetical ordering. Moreover, we note that there is some redundancy in the operators as three of them are the negation of the other three:
Here, the exclamation point denotes a negation, as is does in C++. However, we have used the standard mathematical symbols for operators otherwise.
In addition to the simple number line and linear half-spaces in the videos, relational operators can be used to specify more complex regions like this area above the parabola: