title: C++ vector storing generic T type classes
body: <p>I have a <code>Foo</code> class that expects <code>T</code> type values. I'd also like to store them in a vector. I've tried several methodologies, but didn't find any solutions. Please have a look at the source code below to get the idea what I'd like to achieve.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  template&lt;class T&gt; class Foo
  {
      public:
          T getVar(T var)
          {
              return var;
          }
  };
  
  int main()
  {
      template&lt;class T&gt;
      std::vector&lt;Foo&lt;T&gt;&gt; foos;
  
      Foo&lt;int&gt; foo1;
      Foo&lt;double&gt; foo2;
  
      foos.push_back(foo1); // doesn't work this way
      foos.push_back(foo2);
  
      return 0;
  }
  </code></pre>