title: Function Template Specialization using Base Class
body: <p>I've looked around and not found quite what I'm looking for. Basically I want a function template specialized by a base class. I don't know how to make it use the specialized function.</p>
  
  <p>Meaning...</p>
  
  <pre><code>class IBase
  {
  public:
      virtual std::string func() const = 0;
  };
  
  class MyClass : public IBase
  {
  public:
      std::string func() const { return "From MyClass"; }
  };
  
  template &lt;class T&gt;
  std::string get_func(const T* t)
  {
      return "Unknown";
  }
  
  template &lt;&gt;
  std::string get_func&lt;IBase&gt;(const IBase* t)
  {
      return t-&gt;func();
  }
  
  int main()
  {
      int a;
      MyClass b;
  
      get_func(&amp;a); // &lt;- Returns 'Unknown'. Good.
      get_func(&amp;b); // &lt;- Returns 'Unknown'. Bad, want 'From MyClass'.
  }
  </code></pre>
  
  <p>The reason I use <code>const T*</code> is because <code>IBase</code> is abstract.</p>