title: How to clone as derived object in C++
body: <p>I define two classes in C++.  Ones is the base class, and one is a derived class</p>
  
  <pre><code>    class CBaseClass
      {
      …
      }
  
      class CDerivedClass : public CBaseClass
      {
      …
      }
  </code></pre>
  
  <p>And want to implement a clone function as follows:</p>
  
  <pre><code>    CBaseClass *Clone(const CBaseClass *pObject)
      {
      }
  </code></pre>
  
  <p>When an object of CDerivedClass is passed to Clone, then the function will also create a CDerivedClass object and return.
  When an object of CBaseClass is passed to Clone, then the function will also create a CBaseClass object and return.</p>
  
  <p>How to implement such a feature?</p>