title: Inheritance with templates
body: <pre><code>#include&lt;iostream&gt;
  
  using namespace std; 
  
  class C
   {
  public:
  C (){};
  virtual void nothing()=0;
  virtual ~C (){};
   };
  
  class A : public C
  {
  public:
   A (){};
   virtual void nothing(){};
  };
  class B:public A 
  {
  public:
   B(){};
   void nothing(){};
  };
  
  template &lt;class T&gt;
  void hi(T){
  cout &lt;&lt; " i am something\n";
  }
  
  template &lt;&gt;
  void hi&lt;A&gt;(A)
  {
  cout &lt;&lt; " I am A\n";
  }
  
  template &lt;&gt;
  void hi&lt;B&gt;(B)
  {
  cout &lt;&lt; " I am B\n";
  }
  
  int main ( ) 
  {
  C *array [] = {new A,new B};
  hi (*array [0]);
  hi (*array [1]);
  
  delete array [0];
  delete array [1];
  return 0; 
  
  } 
  </code></pre>
  
  <p>Out: 
  i am something
  I am something</p>
  
  <p>Currently I am writing a program that has to deal with<br>
  Inherited types and specialised templates. In the example above I would l would like to see 
  I am A
  I am B
  Is there a way to properly invoke the functions corresponding to the objects although I am handling a base class array? I am not sure if type checking and conversion via dynamic_cast is the most elegant solution. Note that this is just an excerpt from a larger program.
  Thank you in advance </p>