Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Short Circuit Evaluation guaranteed In C++ as it is in Java?

Tags:

java

c++

Yes, it is guaranteed for the "built in" types. However, if you overload && or || for your own types, short-circuited evaluation is NOT performed. For this reason, overloading these operators is considered to be a bad thing.


Yes. && and || short circuit in C and C++; it is guaranteed by the standard.

See also: Is short-circuiting logical operators mandated? And evaluation order?