it might also help by thinking of how logic gates work. the 8 basic logic operations (2 unary and 6 binary) implemented as inline functions would be:
Code:
inline
bool
relay(bool a)
{
return a;
}
inline
bool
not(bool a)
{
return !a;
}
inline
bool
and(bool a, bool b)
{
return a & b;
}
inline
bool
or(bool a, bool b)
{
return a | b;
}
inline
bool
xor(bool a, bool b)
{
return a ^ b;
}
inline
bool
nand(bool a, bool b)
{
return not(and(a, b));
}
inline
bool
nor(bool a, bool b)
{
return not(or(a, b));
}
inline
bool
xnor(bool a, bool b)
{
return not(xor(a, b));
}
/* eg: */
int
main(void)
{
/* !(1&&(1||0)) */
cout << nand(1, or(1, 0)) << endl;
}
also, by memorizing their truth tables and learning boolean algebra you will be able to verify and simplify boolean expressions with greater ease.