Yes, the &&
operator in C++ uses short-circuit evaluation so that if bool1
evaluates to false
it doesn't bother evaluating bool2
.
"Short-circuit evaluation" is the fancy term that you want to Google and look for in indexes.
The same happens with the ||
operator, if bool1
evaluates to true
then the whole expression will evaluate to true, without evaluating bool2
.
In case you want to evaluate all expressions anyway you can use the &
and |
operators.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…