title: returning instance of derived class from base class member function
body: <p>Is it an O.K. design if i return an instance of Derived class from Base class member function(created using new Derived()) ?</p>
  
  <p>Also this involves the need to forward declare the Derived class and also make the Derived class constructor public.   </p>
  
  <p>Code Sample :-</p>
  
  <pre><code>Class Base
  {
   public:
    Base() {}
    Derived* get_new_derived(int X) 
    { 
      Derived *der = new Derived(X); 
      return der;  
    }
  }
  
  Class Derived : public Base
  {
   private:
    int _X;
   protected:
    Derived(int X) { _X = X; }
   public:  
    Derived* get_new_derived(int X) 
    { 
      Derived *der = new Derived(X); 
      return der;  
    }
  }
  </code></pre>
  
  <p>I have one more derived class(say Derived1). Now let's say :-</p>
  
  <p><strong>Usage1 :</strong> </p>
  
  <pre><code>Derived1* der1 = new Derived1();
  Derived * der = der1-&gt;get_new_derived(10);
  </code></pre>
  
  <p><strong>Usage2 :</strong></p>
  
  <pre><code>Derived1* der1 = new Derived1();
  Base* bs = der1;
  Derived * der = bs-&gt;get_new_derived(10);
  </code></pre>