title: C++ template class specialization: why do common methods need to be re-implemented
body: <p>In the sample:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class B
  {
  public:
      virtual void pvf() = 0;
  };
  
  template &lt;class T&gt;
  class D : public B
  {
  public:
      D(){}
  
      virtual void pvf() {}
  
  private:
      string data;
  };
  
  template &lt;&gt;
  class D&lt;bool&gt; : public B
  {
  public:
      D();
  
      virtual void pvf(){ cout &lt;&lt; "bool type" &lt;&lt; endl; }
  };
  
  int main()
  {
      D&lt;int&gt; d1;
      D&lt;bool&gt; d2;
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>test.cpp:(.text+0x1c): undefined reference to `D&lt;bool&gt;::D()'
  </code></pre>
  
  <p><em>Note that the reason I don't just specialize the D() by itself is I want to eliminate the need for string <code>D&lt;T&gt;::data</code> in the <code>D&lt;bool&gt;</code> case.</em></p>
  
  <p>Why do I need to re-implement <code>D()</code> in <code>D&lt;bool&gt;</code>? Seems like there should be a way for me to tell the compiler to use the version from <code>D&lt;T&gt;</code>.</p>
  
  <p>Is there any way to do a simple specialization like this without having to re-implement methods?</p>