Strange behavior of Boolean type in c++
<p>I have the following if statement in my code:  </p>

<pre><code>~(( APQState  == dot11-&gt;tempState[0] ) &amp;&amp;
  ( STAQState == dot11-&gt;tempState[1] ) &amp;&amp;
  ( tempk1    == dot11-&gt;tempState[2] ) &amp;&amp;
  ( tempk2    == dot11-&gt;tempState[3] ) &amp;&amp;
  ( tempk3    == dot11-&gt;tempState[4] ))
</code></pre>

<p>Let say the boolean variable,  </p>

<pre><code>B = ( APQState  == dot11-&gt;tempState[0] ) &amp;&amp;
    ( STAQState == dot11-&gt;tempState[1] ) &amp;&amp;
    ( tempk1    == dot11-&gt;tempState[2] ) &amp;&amp;
    ( tempk2    == dot11-&gt;tempState[3] ) &amp;&amp;
    ( tempk3    = =dot11-&gt;tempState[4] )
</code></pre>

<p>The if statement is being evaluated even when B is true ( => ~B is false).<br>
I checked the value of B inside the loop when it executes. 
I get B=1;</p>

<p>Strangely when I try to cout the value of (~B ), it shows a value of 2. ( i.e when B = 1).  </p>

<p>Why is this happening?</p>
