Why is there no "logical XOR" in C ++?

6

I was thinking and this question came to me:

"Logical XOR" !

For example:

true  false = true
true  true  = false
false true  = true
false false = false
    
asked by anonymous 10.08.2018 / 03:40

1 answer

9

There is, of course, the result you want, it just does not call logical XOR because it already has a simpler name, it is called different , because This is what it is, it gives true when the operands are different, same as the bitwise XOR , you can test:

#include <iostream>
using namespace std;

int main() {
    cout << (true != false) << endl;
    cout << (true != true) << endl;
    cout << (false != true) << endl;
    cout << (false != false) << endl;
}
    
10.08.2018 / 03:58