Pass by Reference as "essential" to swap method exposed as a lie

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
 
K

KH

Isn't that what I said?

No, you said "binary systems of base 2", implying that binary numbering
could use some other base number.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top