title: Why is redeclaring a template member function allowed in C++?
body: <pre><code>class test{
   public:
   int call();
  };
  
  int test::call();
  
  int main(){return 0;}
  </code></pre>
  <p>The above will not compile, with this error:</p>
  <pre><code>error: declaration of 'int test::call()' outside of class is not definition 
  </code></pre>
  <p>However, the same code is allowed if templates are used as such:</p>
  <pre><code>class test{
   public:
   template&lt;class T&gt;
   int call();
  };
  
  template int test::call&lt;int&gt;(); // what's the point of this line?
  
  template &lt;class T&gt;
  int test::call(){
    T in = 5;
    return in;
  }
  
  int main(){
   test t;
   
   return 0;
  }
  </code></pre>
  <p>I have 2 questions on this:</p>
  <p>1- What's the point of the re-declaration? I have seen similar code in other projects.</p>
  <p>2- Why does it compile and my first code snippet won't?</p>