cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
or execution priority
or execution priority
Feb 10, 2011 at 1:58pm UTC
glushkov
(2)
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;
Feb 10, 2011 at 2:07pm UTC
filipe
(1165)
No. It's called short circuit evaluation. It works the same for &&.
Feb 10, 2011 at 2:09pm UTC
glushkov
(2)
Thanks :)
Feb 10, 2011 at 2:29pm UTC
ne555
(10692)
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.