title: Inheritance in curiously recurring template pattern polymorphic copy (C++)
body: <p>I'm using CRTP to add a clone method to inherited classes, for example:</p>
  
  <pre><code>class Base 
  {
       virtual ~Base() {};
       virtual Base* clone() const = 0;
  }; 
  
  template&lt;class Derived&gt; class BaseCopyable : Base
  { 
  public:
      virtual Base* clone() const
      {
          return new Derived(static_cast&lt;Derived const&amp;&gt;(*this));
      }
  };
  
  class A : public BaseCopyable&lt;A&gt;;
  class B : public BaseCopyable&lt;B&gt;;
  etc...
  </code></pre>
  
  <p>But if I have a class that inherits from B, for example:</p>
  
  <pre><code>class differentB : public B;
  </code></pre>
  
  <p>Then clone() doesn't return an object of type differentB, it returns a B. Besides writing a new clone() method in differentB, is there some way to fix this?</p>
  
  <p>Thanks for reading!</p>