title: Undefined reference error for template method
body: <p>This has been driving me mad for the past hour and a half. I know it's a small thing but cannot find what's wrong (the fact that it's a rainy Friday afternoon, of course, does not help).</p>
  
  <p>I have defined the following class that will hold configuration parameters read from a file and will let me access them from my program:</p>
  
  <pre><code>class VAConfig {
      friend std::ostream&amp; operator&lt;&lt;( std::ostream&amp; lhs, const VAConfig&amp; rhs);
  
  private:
      VAConfig();
      static std::string      configFilename;
      static VAConfig*        pConfigInstance;
      static TiXmlDocument*   pXmlDoc;
      std::map&lt;std::string, std::string&gt; valueHash;
  
  public:
      static VAConfig* getInstance();
      static void setConfigFileName( std::string&amp; filename ) { configFilename = filename; }
      virtual ~VAConfig();
  
      void readParameterSet( std::string parameterGroupName );
      template&lt;typename T&gt; T readParameter( const std::string parameterName );
      template&lt;typename T&gt; T convert( const std::string&amp; value );
  };
  </code></pre>
  
  <p>where the method <code>convert()</code> is defined in <code>VAConfig.cpp</code> as</p>
  
  <pre><code>template &lt;typename T&gt;
  T VAConfig::convert( const std::string&amp; value )
  {
      T t;
      std::istringstream iss( value, std::istringstream::in );
      iss &gt;&gt; t;
      return t;
  }
  </code></pre>
  
  <p>All quite simple. But when I test from my main program using</p>
  
  <pre><code>int y = parameters-&gt;convert&lt;int&gt;("5");
  </code></pre>
  
  <p>I get an <code>undefined reference to 'int VAConfig::convert&lt;int&gt;...'</code> compilation error. Ditto for <code>readParameter()</code>.</p>
  
  <p>Looked at a lot of template tutorials but coul not figure this out. Any ideas?</p>