title: Defining template class member functions in a namespace?
body: <p>I looked around and tried to find an answer to this. Is it possible to define the member functions of a template class in a namespace within a cpp file? I get an error when I try to do it.</p>
  
  <p>Here are the two files I am trying to compile.</p>
  
  <p>ArrayList.hpp</p>
  
  <pre><code>     template&lt;typename T&gt;
       class ArrayList{
            ArrayList();
            ~ArrayList();
       }
  </code></pre>
  
  <p>ArrayList.cpp</p>
  
  <pre><code>    #include "ArrayList.hpp"
  
      namespace{
  
          template&lt;typename T&gt;
          ArrayList&lt;T&gt;::ArrayList(){
  
           /* function body goes here */
  
          }
  
          ArrayList&lt;T&gt;::~ArrayList(){
  
           /* function body goes here */
  
          }
  </code></pre>
  
  <p>Compiler error</p>
  
  <pre><code> error: cannot define or
    redeclare 'ArrayList&lt;T&gt;' here because namespace '' does not enclose
    namespace 'ArrayList'
    ArrayList&lt;T&gt;::ArrayList()
  </code></pre>