Using a unique_ptr as a private member in an abstract base class
<p>I'm fairly new to C++ (but not C or OOP) but I'm trying to do things the "right" way and avoid any bad and/or dangerous habits, so I'm using Google's C++ coding guidelines and Effective C++ as starting points for my learning.</p>

<p>I have an abstract base class with a <code>unique_ptr</code> as a member. If I make it private and only provide access to derived classes via a getter (per Google C++ style guidelines), is this the best way to do it? Or am I missing a potential pitfall here?</p>

<p><strong>Base.h:</strong></p>

<pre><code>#include "Document.h"

typedef std::unique_ptr&lt;Document&gt; pDOC;

class Base {
public:
    Base();
    virtual ~Base() = 0;

    pDOC&amp; GetDoc();

private:
    // Unique pointers cannot be shared, so don't allow copying
    Base(Base const &amp;); // not supported
    Base &amp;operator=(Base const &amp;); // not supported
    pDOC m_doc;
};
</code></pre>

<p><strong>Base.cpp</strong></p>

<pre><code>#include "base.h"

Base::Base()
: m_xmldoc(new Document) {}

// Class destructor (no need to delete m_doc since it is a smart pointer)
Base::~Base() {}

pDOC&amp; Base::GetDoc() {
    return m_doc;
}
</code></pre>
