Template linking problem C++
<p>I have a template class definition that needs to be in the cpp file. Adopting from <a href="http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13" rel="nofollow">http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13</a>, I did something like this:</p>

<pre><code> // File "foo.cpp"
 #include &lt;iostream&gt;
 #include "foo.h"

 template&lt;typename T&gt; void foo()
 {
  std::cout &lt;&lt; "Here I am!\n";
 }

 template void foo&lt;int&gt;();
</code></pre>

<p>I instantiate the template from the .cpp file. However, I need different types like foo(string) etc and I realized that I could only instantiate it once. How could I fix it?</p>

<p>Thanks.</p>
