title: Can I write an interface for a template class in C++
body: <p>I have an interface and a couple of implementations of a class that stores serialized objects.  I'd like to make the implementation classes into template classes so I can use them with more than one type of object, but I'm getting compiler errors.   </p>
  
  <pre><code>#include &lt;iostream&gt;
  template&lt;typename T&gt;
  class Interface{
  public:
      virtual void func(T&amp; c) = 0;
  };
  
  class Container{
  public:
      Container() : dummy(10){}
      int dummy;
  };
  
  
  template&lt;typename T&gt;
  class Implementation : public Interface{
  public:
      void func(T&amp; c){
          std::cout &lt;&lt; "++c.dummy " &lt;&lt; ++c.dummy &lt;&lt; std::endl;
      }
  };
  
  int main(){
      Container c;
      Implementation&lt;Container&gt; i;
      i.func(c);
      return 0;
  }
  </code></pre>
  
  <p>I get "error: expected class-name before ‘{’ token" at the "class Implementation..." line.  </p>
  
  <p>Thanks.</p>