Vlad has already given the correct answer. I'm just adding a simple table that can help show how these problems can be solved.
| v2 = true | v2 = false | -----------+------------+------------+ v1 = true | false | true | -----------+------------+------------+ v1 = false | true | false | -----------+------------+------------+
Edit: The table has been updated to reflect the updated question.
As Vlad already noted, an expression can be reorganized into !=
. Brackets are added for clarification. They are not needed by the compiler.
bool v3 = (v1 != v2);
source share