Name
or operator — Logical or operator
Synopsis
logical-or-expr := logical-or-expr "||" logical-and-expr | logical-or-expr or logical-and-expr
The logical or operator converts its
operands to type bool
and returns a
bool
result. This built-in operator
is a short-circuit operator, so if the left operand is true
, the expression yields true
without evaluating the right operand.
Note that if operator
or
is overloaded, it cannot be
short-circuited and must evaluate both operands.
The keyword or
is
interchangeable with the ||
token.
Example
int* p;
if (p == NULLor
*p == 0)
skip( );
See Also
and
, bitor
, bool
, expression, not
, Chapter
3, <ciso646>
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.