(C++) typeid
February 24, 2017 · View on GitHub
(C++) typeid
typeid is a C++ keyword to determine a type at runtime.
Example
Advice
- Use typeid to implement extended type information [1]
- Use typeid to find the type of an object [2]
- Prefer virtual functions to repeated switch-statements based on typeid or dynamic_cast [3]
References
- 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'
- 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)'
- 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'