or execution priority

When a logical OR of two boolean variables is checked, is the second value going to be checked, if the first is true? In the following example, is b going to be checked?

bool a = true
bool b = false

if(a || b) cout << "true" << endl;

No. It's called short circuit evaluation. It works the same for &&.
Thanks :)
If you don't like that behaviour you could create a Boolean class that overloads the operators or and not and provides a cast to bool.
Topic archived. No new replies allowed.