title: C++ default assignment operator from different type
body: <p>I have the following class as a wrapper around the basic type <code>bool</code>:</p>
  
  <pre><code>class MyBoolean {
  public:
      MyBoolean(bool value = false):value(value) {};
      virtual ~MyBoolean() {};
  
      void MySpecialFunction();
      ...
  
  private:
      bool value;
  }
  </code></pre>
  
  <p>I want to use <code>MyBoolean</code> in expressions as normal <code>bool</code>. That is, assign to it, compare, etc. For that I define the assignment and implicit type cast operators.</p>
  
  <pre><code>inline operator bool() const {
      return value;
  }
  inline bool operator = (const bool &amp;rhs) {
      return value = rhs;
  }
  </code></pre>
  
  <p>It seems however that the assignment operator is not needed. The following code compiles just with type cast operator, without the assignment operator:</p>
  
  <pre><code>MyBoolean b;
  b = true;
  </code></pre>
  
  <p>Why doesn't the compiler complain it cannot assign <code>bool</code> into <code>MyBoolean</code>? What is the default implementation of the assignment operator from a different type in C++?</p>