Namespaces
Variants
Views
Actions

Talk:cpp/language/operator logical

From cppreference.com
< Talk:cpp‎ | language
Revision as of 10:06, 6 February 2020 by 62.201.102.190 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

On bool operands, exactly what operators are allowed?

I guess the assignment operator is allowed.

bool a; bool b = a;


What is the case for example with the equality operator? (==)

bool a; bool b; bool c = (a == b); // VALID (AND SAFE) OR NOT? bool d = (a != b); // VALID (AND SAFE) OR NOT?


How to test (write) properly if boolean a is equivalent to boolean b?

bool c = (a && b || !a && !b); //?

or

bool c = (a ? b : !b); //?

62.201.102.190 10:06, 6 February 2020 (PST)