title: C++: Containers of Arbitrary Template Type
body: <p>In C++, suppose I have a templatized class, like</p>
  
  <pre><code>template &lt;typename T&gt;
  class Foo
  {
      ...
  };
  </code></pre>
  
  <p>and suppose that I have several kinds of Foo objects, like</p>
  
  <pre><code>Foo&lt;int&gt; intFoo = Foo&lt;int&gt;();
  Foo&lt;double&gt; doubleFoo = Foo&lt;double&gt;();
  ...
  </code></pre>
  
  <p>and so on.</p>
  
  <p>Actually, its worse than that. I really want an intFoo object of a class that inherits from Foo&lt; int >, for instance.</p>
  
  <p>I would like to do something like this:</p>
  
  <pre><code>std::vector&lt;Foo&lt;?&gt; &gt; aVector;
  aVector.push_back(intFoo);
  aVector.push_back(doubleFoo);
  </code></pre>
  
  <p>Keeping in mind that I have substantially oversimplified my design case, is there a simple way to do this?</p>