title: C++ using operator int() instead of operator+
body: <p>I'm trying to understand why the <code>operator int()</code> is invoked instead of the defined <code>operator+</code></p>
  
  <pre><code>class D {
      public:
          int x;
          D(){cout&lt;&lt;"default D\n";}
          D(int i){ cout&lt;&lt;"int Ctor D\n";x=i;}
          D operator+(D&amp; ot){ cout&lt;&lt;"OP+\n"; return D(x+ot.x);}
          operator int(){cout&lt;&lt;"operator int\n";return x;}
          ~D(){cout&lt;&lt;"D Dtor "&lt;&lt;x&lt;&lt;"\n";}
  };
  
  void main()
  {
      cout&lt;&lt;D(1)+D(2)&lt;&lt;"\n";
      system("pause");
  }
  </code></pre>
  
  <p>my output is:</p>
  
  <pre><code>int Ctor D
  int Ctor D
  operator int
  operator int
  3
  D Dtor 2
  D Dtor 1
  </code></pre>