title: Create instance of a child class in an abstract base class C++
body: <p>I was wondering if it would be possible to do the same as the code above in C++.
  The idea is to return an instance of a child object in the base class.</p>
  
  <pre><code>public class A
  {
      private B b;
  
      public A()
      {
          b = B.GetDefaultB();
      }
  
      public A(B _b)
      {
          b = _b;
      }
  }
  
  public abstract class B
  {
      public static B GetDefaultB()
      {
          return new C();
      }
  }
  
  public class C : B
  {
      public C()
      {
  
      }
  }
  </code></pre>
  
  <p>I tried to do something </p>
  
  <pre><code>class A
  {
  public:
      A();
      ~A();
  };
  
  A::A(){}
  A::~A(){}
  
  class B
  {
  public:
      B();
      static B* GetDefaultB();
      virtual ~B() = 0;
  };
  
  B::B(){}
  B* B::GetDefaultB()
  {
      return new C();
  }
  B::~B(){}
  
  class C : public B
  {
  public:
      C();
      ~C();
  };
  
  C::C(){}
  C::~C(){}
  </code></pre>
  
  <p>But I think there is a loop in the includes.
  What should I do ?</p>
  
  <p>Thanks in advance !</p>