Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 1.39 KB

run-time-type-information.md

File metadata and controls

31 lines (20 loc) · 1.39 KB
description title ms.custom ms.date helpviewer_keywords ms.assetid
Learn more about: Run-Time Type Information
Run-Time Type Information
index-page
11/04/2016
RTTI compiler option
run-time type information
run time, type checking
type information, run-time type checking
run-time checks, type checking
becbd0e5-0439-4c61-854f-8a74f7160c54

Run-Time Type Information

Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. RTTI was added to the C++ language because many vendors of class libraries were implementing this functionality themselves. This caused incompatibilities between libraries. Thus, it became obvious that support for run-time type information was needed at the language level.

For the sake of clarity, this discussion of RTTI is almost completely restricted to pointers. However, the concepts discussed also apply to references.

There are three main C++ language elements to run-time type information:

  • The dynamic_cast operator.

    Used for conversion of polymorphic types.

  • The typeid operator.

    Used for identifying the exact type of an object.

  • The type_info class.

    Used to hold the type information returned by the typeid operator.

See also

Casting