title: Implementing interfaces in C++
body: <p>I usually program in C# but am trying to do a bit of C++ and am struggling somewhat trying to implement interfaces in C++.</p>
  
  <p>In C# I'd do something like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>class Base&lt;T&gt;
  {
      public void DoSomething(T value)
      {
          // Do something here
      }
  }
  
  interface IDoubleDoSomething
  {
      void DoSomething(double value);
  }
  
  class Foo : Base&lt;double&gt;, IDoubleDoSomething
  {
  }
  </code></pre>
  
  <p>In C++ I've implemented it like this:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template &lt;class T&gt;
  class Base
  {
  public:
      virtual void DoSomething(T value)
      {
          // Do something here
      }
  };
  
  class IDoubleDoSomething
  {
  public:
      virtual void DoSomething(double value) = 0;
  };
  
  class Foo : public Base&lt;double&gt;, public IDoubleDoSomething
  {
  };
  </code></pre>
  
  <p>The problem is that I <strong>cannot instantiate Foo because it is abstract</strong> (doesn't implement DoSomething). I realise I can implement DoSomething and just call the method on Base but I was hoping there is a better way of doing this. I have other classes which inherit from base with different data types and I have other classes which inherit from IDoubleDoSomething which don't use Base.</p>
  
  <p>Any help appreciated.</p>