title: Passing int as bool argument in C++
body: <p>could someone explain what happens in this code:</p>
  <p><strong>example here:</strong> <a href="https://ideone.com/1cFb4N" rel="noreferrer">https://ideone.com/1cFb4N</a></p>
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class toto
  {
  public:
      bool b;
      toto(bool x)
      {
          cout&lt;&lt; &quot;constructor bool:&quot; &lt;&lt; (x ? &quot;true&quot;: &quot;false&quot;)&lt;&lt;endl;
          b = x;
      }
      ~toto() {}
  };
  
  int main()
  {
      toto t = new toto(0);
      cout &lt;&lt; &quot;t.b is &quot; &lt;&lt; (t.b ? &quot;true&quot;: &quot;false&quot;)&lt;&lt;endl;
      t = new toto(false);
      cout &lt;&lt; &quot;t.b is &quot; &lt;&lt; (t.b ? &quot;true&quot;: &quot;false&quot;)&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  <p>output:</p>
  <pre><code>constructor bool:false
  constructor bool:true
  t.b is true
  constructor bool:false
  constructor bool:true
  t.b is true
  </code></pre>