title: Why is base class' assignment operator called?
body: <p>In the following code I understand that the assignment operator in the struct <em>d</em> is not called on <code>derived1 = derived2;</code> and instead the default assignment operator is generated and called.
  However I am confused as to why:</p>
  <p>Why is not the explicit <em>d</em> assignment operator called on <code>derived1 = derived2;</code> when the upcasting is implicit in <code>b &amp; base2  = derived1</code>?<br />
  <strong>My guess</strong> is that the default <code>operator=</code> (with header <code>void operator=(const derived&amp; d)</code>) is always generated unless explicitly overloaded with the exact same header and will always match with an assignment made of two variables of that same type. Am I on the right path?</p>
  <pre><code>struct b {
     int x;
     void operator=(const b&amp; base) {
        std::cout &lt;&lt; &quot;base&quot; &lt;&lt; std::endl;
     }
  }
  
  struct d: b {
     int y;
     void operator=(const b&amp; base) {
        std::cout &lt;&lt; &quot;derived&quot; &lt;&lt; std::endl;
     }
  }
  
  int main() {
     b base1;
     d derived1;
     d derived2;
     b &amp; base2 = derived1;
  
     derived1 = base1; // output: &quot;derived&quot;
     derived1 = derived2; // output &quot;base&quot;
  }
  </code></pre>