title: Template class with template function
body: <p>Can anyone tell what is wrong with this piece of code?</p>
  
  <pre><code>template&lt;class X&gt;
  class C {
  public:
      template&lt;class Y&gt; void f(Y); // line 4
  };
  
  template&lt;class X, class Y&gt;
  void C&lt;X&gt;::f(Y y) { // line 8
      // Something.
  }
  
  int main() {
      C&lt;int&gt; c;
      char a = 'a';
      c.f(a);
      return 0;
  }
  </code></pre>
  
  <p>Compilation:</p>
  
  <pre><code>$ g++ source.cpp 
  source.cpp:8: error: prototype for ‘void C&lt;X&gt;::f(Y)’ does not match any in class ‘C&lt;X&gt;’
  source.cpp:4: error: candidate is: template&lt;class X&gt; template&lt;class Y&gt; void C::f(Y)
  </code></pre>
  
  <p>I now that I can accomplish the task by declaring and defining the function at line 4, but what would be the consequences of declaring and defining the function at the same time compared to doing it separately? (This is not a discussion about declaring a function at header vs source file)</p>
  
  <p><strong>Note:</strong> I have seen <a href="https://stackoverflow.com/questions/5512910/explicit-specialization-of-template-class-member-function">this question</a> but is seems that the only part that interests me was left apart =(</p>