Show: Object Pascal C++
Display Preferences

typeid

From Appmethod Topics
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index

Go Up to Run-Time Type Identification (RTTI) Index


Category

Operators, C++ Specific Keywords

Syntax

typeid(expression)
typeid(type-name)

Description

You can use typeid to get run-time identification of types and expressions. A call to typeid returns a reference to an object of type const type_info. The returned object represents the type of the typeid operand.

If the typeid operand is a dereferenced pointer or a reference to a polymorphic type, typeid returns the dynamic type of the actual object pointed or referred to. If the operand is non-polymorphic, typeid returns an object that represents the static type.

You can use the typeid operator with fundamental data types as well as user-defined types.

When the typeid operand is a class object/reference, typeid returns the static rather than run-time type.

If the typeid operand is a dereferenced NULL pointer, the bad_typeid exception is thrown.

See also

Personal tools
In other languages