title: Get type of variable
body: <p>If I understand correctly, typeid can determine the actual type in polymorphism, while typeof cannot.</p>
  
  <p>Is it also true that their returns are used for different purposes: the return of typeof is used as type keyword that can define variable, but the return of typeid cannot?</p>
  
  <p>Is there any way to both get the actual type for polymorphism and use the return as type keyword to define another variable? I hope to get the derived class type from a pointer pointing to the base class and define a variable of or a pointer to the derived class. Something like:</p>
  
  <pre><code>baseclass *p = new derivedclass  
  typexxx(*p) *pp = dynamic_cast&lt;typexxx(*p) *&gt; (p); 
  // would like to convert the pointer from pointing to a base class 
  // to its derived class
  </code></pre>
  
  <p>Thank you very much!</p>