title: How does RTTI work?
body: <p>I have some confusion regarding the RTTI mechanism in C++.</p>
  
  <p>Suppose in have class A and class B that inherits from A. Now consider the following code:</p>
  
  <pre><code>B* b = new B();
  A* a = dynamic_cast&lt;A*&gt;(b);
  </code></pre>
  
  <p>I know that polymorphic classes with virtual methods have virtual tables and vptr's, but I thought that the pointers only give information about the virtual functions. How does the program know at runtime the type of b, using vptr's and vtables?</p>