title: Is it possible to attach a name to a runtime class in C++?
body: <p>I have an hierarchy of classes, the base class having a function to print the class name:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class base
  {
  public:
    virtual void print_name() { cout &lt;&lt; typeid(*this).name() &lt;&lt; endl; };
  };
  
  class derived1 : public base { };
  
  class derived2 : public base { };
  
  int main ()
  {
    base Base;
    Base.print_name();
  
    derived1 Derived1;
    Derived1.print_name();
  
    derived2 Derived2;
    Derived2.print_name();
  }
  </code></pre>
  
  <p>The output of the above is</p>
  
  <pre><code>class base
  class derived1
  class derived2
  </code></pre>
  
  <p>which is, in fact, platform dependent.</p>
  
  <p>Is there a more or less standard way to "attach" some unique name to each class, so it could be used in <code>printname()</code> making the output the same for all platforms (and independent of any changes made to real class names)?</p>