title: C++ assignment operator in derived class
body: <p>I don't quite understand why for an assignment a derived class do not call the corresponding operator of the base class, if its own does not exist. Look at the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class A{
  protected:
    void myWrite(){
      cout &lt;&lt; " Base " &lt;&lt;endl;
    }
  public:
    double x,y;
    A(): x{0},y{0}{};
    virtual A &amp; operator=(double g){x=g;y=g;return *this;}
    virtual ~A(){};
    virtual void doneit(){myWrite();}
  };
  
  
  class B: public A{
  protected:
  public:
    B():A(){};
    virtual ~B(){};
    virtual void doneit(){myWrite();}
  };
  
  int main() {
    A jj;
    B pp;
  
    pp=0.0;
    return 0;
  }
  </code></pre>
  
  <p>As it is the code does not compile. Of course if I define an "operator=" for B identical to that for A, everything works, but why the B "operator=" is not called by default if the one in the derived class is not defined?? Could you help shed some light on this issue?</p>
  
  <p>The gcc compiler says ../src/tito.cpp:40:4: error: no viable overloaded '='
          pp=0.0;
          ~~^~~~
  ../src/tito.cpp:28:7: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'double' to 'const B' for 1st argument
  class B: public A{
        ^
  1 error generated.</p>
  
  <p>Could you explain why it doesn't work?</p>