title: C++ inheritance in template parameter
body: <p>I need to pass template as function argument, but template must accept all inherited objects.</p>
  
  <p>For example:</p>
  
  <pre><code>template &lt;class T&gt;
  class Template {
  public:
      Template() {}
  };
  
  // IMPORTANT: must accept all children of "Base"
  class Test {
      Template&lt;Base&gt; *pointer;
  public:
      Test(Template&lt;Base&gt; *pointer) {...}
  };
  
  
  main() {
      Template&lt;Base&gt; *base = new Template&lt;Base&gt;();
      Template&lt;Child1&gt; *child = new Template&lt;Child1&gt;();
  
      Test *test1 = new Test(base);    // WORKING
      // NEXT LINE IS IMPORTANT:
      Test *test2 = new Test(child);   // ERROR: no matching function for call to 'Test::Test(Template&lt;Child1&gt;*&amp;)'
  }
  
  
  class Base {...};
  class Child1 : public Base {...};
  class Child2 : public Base {...};
  ..
  </code></pre>
  
  <p>I need the most effective way, how to store template in "Test" class, that will accept all children classes. I have lot's of children classes.</p>
  
  <p>1) Is it possible to make some up casting (static_cast) for Child class in argument? It will be good to use it inside of "Template" or inside of "Test" class. Not, when creating new "Test" object, because there will be lot's of new objects.</p>
  
  <p>2) Or pass argument without template argument <code>Test(Template *pointer) {...}</code>?</p>
  
  <p>Or how to solve it?</p>