title: Override a class method with a template method in C++
body: <p>I'm still figuring out C++, and I have not been able to put this together from searching on google. I'm working with a larger project used by other people and I'm trying to expand the functionality of a class without breaking anyone else's code. In particular there is an untouchable Base class and Derived class that both implement a "crunch numbers" method that works on std::vector.</p>
  
  <pre><code>class Base {
   public:
      void crunch_numbers(std::vector&amp; v) { // do stuff to v; }
  };
  
  class Derived : public Base {
   public:
      void crunch_numbers(std::vector&amp; v) override { // do different stuff to v; }
  };
  </code></pre>
  
  <p>I'm working with Eigen::Vector, and I was hoping to get away with something like this:</p>
  
  <pre><code>template &lt;typename vec&gt;
  class MyDerived : public Base {
   public:
      void crunch_numbers(vec&amp; v) override { // do different stuff to v; }
  };
  
  typedef MyDerived&lt;std::vector&gt; Derived;
  </code></pre>
  
  <p>That would let me work with different vectors and wouldn't break any existing code that uses the Derived class. But, when compiling my code, I get the error error: <code>‘void MyDerived&lt;vec&gt;::crunch_numbers(vec) [with vec = Eigen::Matrix&lt;double, 2, 1&gt;]’ marked ‘override’, but does not override.</code> ... Because Base class only operates on std::vector. </p>
  
  <p>I can't touch Base class because there may be other derived classes I don't know about. I'd like to have the flexibility to work with different vector types in the future without just adding overloads to Derived class. Is there a way to do this?</p>