title: Print type of object referenced by base-class pointer in C++?
body: <p>If I have class A, and class B which subclasses A, should <code>typeid(x)</code> give the type of A or the type of B, if x is given by:</p>
  
  <p><code>A *x = new B();</code></p>
  
  <p>In my tests I get the type of A - which is not very useful - but I'm not sure if that's due to how C++ works, or if this is due to compiler settings?</p>