Skip to content

Instantly share code, notes, and snippets.

@MihailJP
Created September 6, 2012 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MihailJP/3652275 to your computer and use it in GitHub Desktop.
Save MihailJP/3652275 to your computer and use it in GitHub Desktop.
Logical (not bitwise) XOR in C++
#include <iostream>
int main() {
int a = 1; int b = 2;
if ((bool)a != (bool)b)
std::cout << "a xor b -> true" << std::endl;
else
std::cout << "a xor b -> false" << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment