title: partial specified template class with nontype parameter in C++
body: <p>In following code, I got an compiling error</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  template &lt;typename T, int I&gt;
  class MyClass {
  public:
      void func1(){
      cout&lt;&lt;"default: func1"&lt;&lt;endl;
      }
      void func2(){
      cout&lt;&lt;"default: func2"&lt;&lt;endl;
      }
  private:
      T haha;
  };
  
  template &lt;typename T&gt;
  void MyClass&lt;T, 1&gt;::func1(){
      cout&lt;&lt;"special: func1"&lt;&lt;endl;
  };
  
  
  
  int main()
  {
      MyClass&lt;int, 2&gt; intclass;
      intclass.func1();
      intclass.func2();
  
      MyClass&lt;double, 1&gt; doubleclass;
      doubleclass.func1();
      doubleclass.func2();
      return 0;
  }
  </code></pre>
  
  <p>I got following compiling error:</p>
  
  <pre><code>partialspecifizednontype.cpp:19: error: invalid use of incomplete type 'class MyClass&lt;T, 1&gt;'
  partialspecifizednontype.cpp:6: error: declaration of 'class MyClass&lt;T, 1&gt;'
  </code></pre>
  
  <p>Any specific reason that I can't do this? Is there any workaround to achieve this?</p>
  
  <p>I notice that if my template class don't have first parameter things are OK. (my gcc is 4.2.1)</p>
  
  <p>Following example is OK:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  template &lt;int I&gt;
  class MyClass {
  public:
      void func1(){
      cout&lt;&lt;"default: func1"&lt;&lt;endl;
      }
      void func2(){
      cout&lt;&lt;"default: func2"&lt;&lt;endl;
      }
  };
  
  template&lt;&gt;
  void MyClass&lt;1&gt;::func1(){
      cout&lt;&lt;"special: func1"&lt;&lt;endl;
  };
  
  
  
  int main()
  {
      MyClass&lt;2&gt; intclass;
      intclass.func1();
      intclass.func2();
  
      MyClass&lt;1&gt; doubleclass;
      doubleclass.func1();
      doubleclass.func2();
      return 0;
  }
  </code></pre>