title: C++ polymorphism with template interface
body: <p>Timer.h:</p>
  
  <pre><code>template&lt;class T&gt;
  class Timer {
      public:
        typedef T Units;
  
      virtual Units get() = 0;
  };
  </code></pre>
  
  <p>TimerImpl.h:</p>
  
  <pre><code>class TimerImpl: public Timer&lt;long&gt; {
  public:
  
  TimerImpl() {
  }
  
  ~TimerImpl() {
  
  }
  
  long get();
  
  };
  </code></pre>
  
  <p>FpsMeter.h(version 1):</p>
  
  <pre><code>template &lt;class T&gt; 
  class FpsMeter {
      private:
      Timer&lt;T&gt;* timer;
  
      public:
      FpsMeter (Timer&lt;T&gt;* timer) {
          this-&gt;timer = timer;
      }
  
      ...
  
  };
  </code></pre>
  
  <p>This example works. But it does not look pretty.</p>
  
  <pre><code>Timer&lt;long&gt;* t = new TimerImpl();
  FpsMeter&lt;long&gt;* f1  = new FpsMeter&lt;long&gt; (t);
  </code></pre>
  
  <p>Here there are a lot of extra template uses. How can I realize this idea of multy-type interface when the type is defined by the implementation and user class has not to define new type, it should use the type of the implementation.</p>