title: Inheritance of overloaded + operator
body: <p>I have a problem in inheriting overloaded + operator.
  Let me make an example.</p>
  
  <pre><code>class Data{
  protected:
      int data[3];
  public:
      Data(){
          data[0] = data[1] = data[2] = 0;
      }
  
      Data operator+(const Data&amp; other)
      {
          Data temp = *this;
          for(int i=0;i&lt;3;i++){
              temp.data[i] += other.data[i]
          }
          return temp;
      }
  };
  
  class DataInterited:public Data{
  public:
  
  };
  /******************Main*****************/
  DataInterited d1,d2,d3;
  d3 = d1 + d2;  //=&gt; This is compile error
  </code></pre>
  
  <p>This code generate compile error saying,</p>
  
  <blockquote>
    <p>no match for ‘operator=’ (operand types are ‘DataInterited’ and ‘Data’)</p>
  </blockquote>
  
  <p>I think I have to implement <code>operator+</code> for <code>DataInherited</code> so that it return <code>DataInherited</code> instance. <strong>But in this way, I cannot avoid code duplication.</strong></p>
  
  <p>Is there any way to make <code>d3=d1+d2;</code> line correct while avoiding duplicating the <code>+ operator</code> implementation?</p>