title: understanding virtual copy constructors
body: <p>I'm having trouble understanding what's really happening with the code in a book I'm using to learn C++. Here's the code:</p>
  
  <pre><code>class Base
  {
      public:
          Base() {};
          virtual ~Base() {};
  
          virtual Base* Clone() {return new Base(*this);}
  };
  
  class Derived
  {
      public:
          Derived() {};
          virtual ~Derived() {};
  
          virtual Base* Clone() {return new Derived(*this);}
  };
  </code></pre>
  
  <p>So in this <code>Clone()</code> function I understand that the function returns a pointer to a Base class object. What I don't understand is what's happening within that function. When I've previously used <code>new</code> as in <code>int *pInt = new int</code>, I was under the impression that <code>new</code> essentially allocates enough memory on the free store for an integer, then returns that address, applying the address to the pointer <code>pInt</code>. With that same logic I'm trying to understand the <code>new Derived(*this)</code> portion of the code. So, I think it is allocating enough memory on the free store for a Derived class object, and returning the address, which is then returned by the function <code>Clone()</code>.</p>
  
  <p>Why, though, does it pass <code>*this</code> through the constructor, if that is a constructor? I understand <code>*this</code> means its passing the address of whatever object is being cloned, but I don't understand the syntax of <code>class_name(address_of_an_object)</code> in the context of the <code>new</code> function. </p>
  
  <p>Could someone please explain what's happening in that portion?</p>
  
  <p>Thanks in advance.</p>