I'll try to explain...

"*" = "AND", + = "OR", 1 = on(true), 0 = off(false). Now imagine a circuit:

if A is on, then the electrical current will go throught... In other words:

1 * 0 = 0

0 * 0 = 0

1 * 1 = 1

0 * 1 = 0

or simply A * B = AB

now imagine another kind of "circuit":

What happens if you turn on A "OR" B? electrical current will pass throught if one or both are on. So:

1 + 0 = 1

1 + 1 = 1

0 + 0 = 0

0 + 1 = 1

Or simply A + B = A + B

Then if A = 0, A * B = A(0 * ?), A + B = B(0 + ?)

NOT(~ in C++) simply inverts.. So if A = 0, ~A = 1

| in C++ = OR(+)

& in C++ = AND(*)

^ in C++ = XOR(Exclusive OR)

Now you should understand, I think...

if you forget something, remember the circuit thing...

One last example:

Code:

__A__
---A--|_____|------
B

It is the same as A * (A + B).

The result should be easy to calculate, right? A * (A + B) = A

Sorry if it is any hard to understand, but my english is not the best to explain this kind of thing... Its almost as "easy" as explain physics in another language...

About XOR...

1 + 1 = 0

0 + 1 = 1

1 + 0 = 1

0 + 0 = 0

The result will be 0 if both are equal, 1 otherwise