title: How-to specialize template method in subclass(c++)?
body: <p>I'm trying to specialize a template method of non-template class in its subclass:</p>
  
  <p>// .h file</p>
  
  <pre><code>class MyWriter {
  public:
      template&lt;typename T&gt;
      void test(const T &amp; val) {
          std::cout &lt;&lt; val &lt;&lt; "\n";
      }
  };
  </code></pre>
  
  <p>// .cpp file</p>
  
  <pre><code>class MyType {
  public:
      MyType(int aa, double dd) : a(aa), d(dd) {}
      int a;
      double d;
  };
  
  class MyWriterExt : public MyWriter {
  public:
      template&lt;&gt; void test(const MyType &amp;val) {
          test(val.a);
          test(val.d);
      }
  };
  
  int main() {
      MyWriterExt w;
      w.test(10);
      w.test(9.999);
      w.test(MyType(15, 0.25));
   return 0;
  }
  </code></pre>
  
  <p>But I receive an error:</p>
  
  <pre><code>Error 1 **error C2912**: explicit specialization; 
  'void MyWriterExt::test(const MyType &amp;)' is not a specialization of a function 
      template \testtemplate.cpp 30
  </code></pre>
  
  <p>How do I extend MyWriter class to support user defined classes?</p>