Question:
if i want to xor 2 values in C/C++, i can do this like this using:
( (p || q) && !(p && q) )
which is equivalent to p xor q.
How do i implement an xor function, that looks like p xor q?
Example:
Code:
int main()
{
bool a,b;
a=true; b=true;
if (a xor b)
printf("true\n");
else
printf("false\n");
return EXIT_SUCCESS ;
}
I can of course do a function like:
Code:
bool xor(bool p, bool q)
{
return ( (p || q) && !(p && q) )
}
But then the function call looks like:
if( xor(a,b) )
and i want: if ( a xor b )
Can I do that at all in C/C++?
Bookmarks