title: Why is this declaration of a function in template class invalid?
body: <p>Consider the following code:</p>
  
  <pre><code>template&lt;int X, int Y&gt;
  struct S
  {
      typedef int func(int,float) const;
  };
  
  template&lt;int X&gt;
  struct D : public S&lt;X,6&gt;
  {
      typename S&lt;X,6&gt;::func func;
  };
  template&lt;int X&gt;
  int D&lt;X&gt;::func(int,float) const
  {
      return 1;
  }
  //----------------
  struct W : public S&lt;7,8&gt;
  {
      S&lt;7,8&gt;::func func;
  };
  int W::func(int,float) const
  {
      return 2;
  }
  
  #include &lt;iostream&gt;
  int main()
  {
      W w;
      std::cout &lt;&lt; w.func(1,4.3) &lt;&lt; "\n";
      D&lt;3&gt; d;
      std::cout &lt;&lt; d.func(1,4.3) &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>If I comment out the code declaring class <code>D</code> and <code>D::func()</code> as well as the corresponding lines in <code>main()</code>, the code compiles normally, and I see <code>2</code> in output, as expected.</p>
  
  <p>But when I make the derived class template (adding <code>typename</code> before function declaration, as <code>S&lt;X.6&gt;</code> is a dependent scope), I get the following errors:</p>
  
  <pre><code>test.cpp:13:27: error: no ‘int D&lt;X&gt;::func(int, float) const’ member function declared in class ‘D&lt;X&gt;’
   int D&lt;X&gt;::func(int,float) const
                             ^
  test.cpp: In instantiation of ‘struct D&lt;3&gt;’:
  test.cpp:32:10:   required from here
  test.cpp:10:27: error: field ‘D&lt;3&gt;::func’ invalidly declared function type
       typename S&lt;X,6&gt;::func func;
                             ^
  </code></pre>
  
  <ul>
  <li>Why can't I declare <code>func</code> in a template derived class, while in non-template class it's OK?</li>
  <li>What exactly is "invalidly declared function type"? what is invalid here?</li>
  </ul>