Declaring function Templates within a namspace and using in a class
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file">Why can templates only be implemented in the header file?</a><br>
  <a href="http://stackoverflow.com/questions/4100893/undefined-reference-to-template-members">Undefined reference to template members</a><br>
  <a href="http://stackoverflow.com/questions/5612791/c-template-and-header-files">c++ template and header files</a>  </p>
</blockquote>



<p>I am getting a compiler error when using a function template in a class. The function template was declared in a namespace in a separate source and header file.  </p>

<p>Here is some example code.</p>

<pre><code>namespace A header file

namespace A {

...
...
 template&lt;typename T1, typename T2 &gt;
 bool OR(T1* j, vector&lt;T2*&gt;, float cut);

...
...
}

A cpp file

namespace A {

 ...
 ...
  template&lt;typename T1, typename T2 &gt;
  bool OR(T1* j, vector&lt;T2*&gt;, float cut){

      ....
      ....

  }

 }
</code></pre>

<p>I then use this namespace in a class</p>

<pre><code>class B cpp file ( only member function)

#include "A.h"

void B::exmaple(){


    if(A::OR(m_ptrObj, m_ptrvectortoOtherObj, m_cut)){

       cout  &lt;&lt; "its true" &lt;&lt; endl;

    }

 }
</code></pre>

<p>So the compiler error I get is as follows (Note this is the error from my real code, but same idea).</p>

<pre><code>undefined reference to `bool JetFilters::OR&lt;Jet, Jet&gt;(Jet*, std::vector&lt;Jet*, std::allocator&lt;Jet*&gt; &gt;*, float)
</code></pre>

<p>Any ideas why I am getting the above error??</p>
