(C++) typeid

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) typeid

 

typeid is a C++ keyword to determine a type at runtime.

 

 

 

 

 

Example

 

 

 

 

 

 

Advice

 

 

 

 

 

References

 

  1. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 22.7. Advice. page 663: '[8] Use typeid to implement extended type information'
  2. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 22.7. Advice. page 663: '[9] Use typeid to find the type of an object (and not to find an interface to an object)'
  3. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 22.7. Advice. page 663: '[10] Prefer virtual functions to repeated switch-statements based on typeid or dynamic_cast'