title: Template specialization and inheritance
body: <p>Suppose I have a template class with a lot of functions and I want to specialize them to change only a few of them and keep the other ones exactly as specified in the base template class.</p>
  
  <p>How can I do that?</p>
  
  <p>Below is what I want to achieve, but the solution isn't good, because it does not allow me to refer to the specialization for <code>int</code> as <code>Base&lt;int&gt;</code> &ndash; I need to use <code>IntSpec</code> for that.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  template&lt;typename T&gt;
  struct Base
  {
    void print1() {cout &lt;&lt; "Base::print1" &lt;&lt; endl;};
    void print2() {cout &lt;&lt; "Base::print2" &lt;&lt; endl;};
  };
  
  struct IntSpec : public Base&lt;int&gt;
  {
    void print2() {cout &lt;&lt; "Base&lt;int&gt;::print2()" &lt;&lt; endl;};
  };
  
  int main()
  {
    Base&lt;double&gt; d;
    // Base&lt;int&gt; i;  &lt;-- I want this kind of instantiation
    IntSpec i;
  
    d.print1();
    d.print2();
    i.print1();
    i.print2();
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>Base::print1
  Base::print2
  Base::print1
  Base&lt;int&gt;::print2()
  </code></pre>