title: c++ Object creating new instances of same type
body: <p>Is there a way to give an object the possibility to create new objects of it's own type, without specifying this type?</p>
  
  <pre><code>class Foo {
  public:
      virtual Foo* new_instance() {
          return new type_of(this); // Some magic here
      }
  };
  
  class Bar: public Foo {
  
  };
  
  Foo* a = new Foo();
  Foo* b = new Bar();
  Foo* c = a-&gt;new_instance();
  Foo* d = b-&gt;new_instance();
  </code></pre>
  
  <p>I would now like <code>c</code> to be of type <code>Foo</code>, while <code>d</code> should be of type <code>Bar</code>.</p>