title: copy constructor is implicitly deleted because the default definition would be ill-formed
body: <p>I've got a class <code>A</code> (from a library over which I have no control)  with a private copy constructor and a <code>clone</code> method, and a class <code>B</code> derived from <code>A</code>. I would like to implement <code>clone</code> for <code>B</code> as well.</p>
  
  <p>The naive approach</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;memory&gt;
  
  class A { // I have no control here
    public:
      A(int a) {};
  
      std::shared_ptr&lt;A&gt;
        clone() const
        {
          return std::shared_ptr&lt;A&gt;(new A(*this));
        }
  
    private:
      A(const A &amp; a) {};
  };
  
  class B: public A {
    public:
      B(int data, int extraData):
        A(data),
        extraData_(extraData)
      {
      }
  
      std::shared_ptr&lt;B&gt;
      clone() const
      {
        return std::shared_ptr&lt;B&gt;(new B(*this));
      }
  
    private:
      int extraData_;
  };
  
  int main() {
    A a(1);
  }
  </code></pre>
  
  <p>however, fails, since the copy constructor of <code>A</code> is private:</p>
  
  <pre><code>main.cpp: In member function ‘std::shared_ptr&lt;B&gt; B::clone() const’:
  main.cpp:27:42: error: use of deleted function ‘B::B(const B&amp;)’
       return std::shared_ptr&lt;B&gt;(new B(*this));
                                        ^
  main.cpp:17:7: note: ‘B::B(const B&amp;)’ is implicitly deleted because the default definition would be ill-formed:
   class B: public A {
         ^
  main.cpp:14:5: error: ‘A::A(const A&amp;)’ is private
       A(const A &amp; a) {};
       ^
  main.cpp:17:7: error: within this context
   class B: public A {
  </code></pre>
  
  <p>There might a way to make use of <code>A::clone()</code> for <code>B::clone()</code>, but I'm not sure how this would work exactly. Any hints?</p>