title: how to inherit methods operator=, clone and dispose
body: <p>I got the hint that for classes with member variables which are pointers, I need to pay attention to properly memory-manage them on assignment. The following methods are meant to avoid memory leaks:</p>
  
  <pre><code>class SomeClass {
  
  SomeClass&amp; SomeClass::operator =(SomeClass&amp; from) {
      // clone
      if (&amp;from != this) {
          this-&gt;dispose();
          this-&gt;clone(from);
      }
      return *this;
  }
  
  void SomeClass::clone(const SomeClass&amp; from) {
      this-&gt;array = from.array;
  }
  
  void SomeClass::dispose() {
      delete[] this-&gt;array;
  }
  };
  </code></pre>
  
  <p>Assuming this is correct so far, is it possible to do the following:</p>
  
  <p>Define a superclass <code>Object</code> which implements <code>operator=</code> and has abstract methods <code>clone</code> and <code>dispose</code>. Any class with pointer members should have <code>Object</code> as a superclass, so that it inherits <code>operator=</code> and I am reminded that I need to implement <code>clone</code> and <code>dispose</code>.</p>
  
  <ul>
  <li>How would such a superclass look like?</li>
  <li>Is it a good idea to do this by inheritance?</li>
  </ul>