B
Ben Voigt [C++ MVP]
Family said:That code does not compile, as Booleans (boolean is not defined), can
not be multiplied or added.
Operator '*' cannot be applied to operands of type 'bool' and 'bool'
C:\...\Program.cs 24 9 SwapCode
Operator '+' cannot be applied to operands of type 'bool' and 'bool'
C:\...\Program.cs 24 9 SwapCode
* and + are "and" and "or" operations in conventional notation. C, C++, C#,
Java all use "&" and "|" for this.
Note the remaining problem with the uninitialized variable.
But he did indeed get DeMorgan's theorem wrong, it is:
/(A + B) = (/A) * (/B)
or in C# style
!(A | B) == (!A) & (!B)
The identity holds for all combinations of boolean A and B