title: Create object of class inherited from type provided by different object
body: <p>I have the following classes</p>
  
  <pre><code>class CommonStyle
  {};
  
  class Style1 : public CommonStyle
  {};
  
  class Style2 : public CommonStyle
  {};
  
  class Style3 : public CommonStyle
  {};
  
  template&lt;typename T&gt; class ZStyle : public T
  {
  };
  </code></pre>
  
  <p>I have object which can be type of Style1, Style2, Style3. 
  How can I create object of ZStyle inherited from Style1 or Style2 or Style3 depend on provided object?</p>
  
  <pre><code>//pseudo-code
  int _tmain(int argc, _TCHAR* argv[])
  {
   CommonStyle* obj1 = new Style1();
   CommonStyle* obj2 = new Style2();
   CommonStyle* obj3 = new Style3();
  
   ZStyle* zobj1 = create_object_inherited_from_style1(obj1);
   ZStyle* zobj2 = create_object_inherited_from_style2(obj2);
   ZStyle* zobj3 = create_object_inherited_from_style3(obj3);
  }
  </code></pre>
  
  <p>Is it possible to avoid dynamic_cast?</p>