if() statements take a bool. Think of it like a function, taking a single bool parameter.
Observe:
int myInteger = 0;
if(myInteger == 0)
The '==' symbol is actually a function with special syntax:
bool operator==(int, int)
It takes two parameters (one on the left of the == and one on the right), and returns a bool that is 'true' if they are both equal.
Try this code:
bool theTwoAreEqual = (myInteger == 0);
if() statements, being similar to (but not exactly) a function that takes a single parameter, and that parameter is always a single bool.
bool equation = (myInteger == 0);
if(equation)
{
//...do stuff...
}
You don't need to say:
if((myInteger == 0) == true)
bools are already true or false. if() statements already take a bool. The code:
if(myBool == true)
...is unnecessarily redundant, but a perfectly acceptable coding style.
The == function takes two values and returns a bool if they are equal.
The != function takes two values and returns a bool if they are not equal.
Likewise the < > <= >= functions return bools.
The ! operator also returns a bool.
The && and || operators also return bools:
bool result = (boolOne && boolTwo) || !boolThree;
If you have a bool already, you might as well just pass it to the if() statement, but there's no real harm in doing it the other way.
If statements say, "if(whatever in here is true)". Bools already know whether they are true or not without having to do comparison.