title: Using typeid to get name of derived class
body: <p>I'm creating a resource manager that takes in classes derived from the class <code>Resource</code>. My problem is that typeid(..).name() returns the wrong name of the class. </p>
  
  <p>I want to add resources like Texture to a map like this:</p>
  
  <pre><code>typedef std::unordered_map&lt;std::string, Resource*&gt; ResourceMap;
  </code></pre>
  
  <p>And I want the name of the 'class + counter' to be the string/name of the Resource. Unfortunately everything just ends up being called <code>P8Resource</code> because these classes derive from 'Resource'. An untimely predicament indeed, but typeid must know somehow that <code>texture</code> is a Texture, not Resource.</p>
  
  <pre><code>class Resource {}; // abstract
  
  class Texture : public Resource {};
  
  Resource *texture = new Texture();
  Texture *texture2 = new Texture();
  
  typeid(texture).name(); // yields 'Resource'
  typeid(texture2).name(); // yields 'Texture'
  </code></pre>
  
  <p>How can I make the first <code>typeid</code> statement yield 'Texture' without using type conversions? </p>