# <typeinfo> <typeinfo> # `` * * * Include the standard header **``** to define several types associated with the type-identification operator **`typeid`**, which yields information about both static and dynamic types. namespace std { class type_info; class bad_cast; class bad_typeid; } // namespace stdCopy to clipboard ## `bad_cast` class bad_cast : public exception { };Copy to clipboard The class describes an exception thrown to indicate that a **dynamic cast** expression, of the form: dynamic_cast(expression)Copy to clipboard generated a null pointer to initialize a reference. The value returned by `what()` is an implementation-defined [C string](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#C%20string). None of the member functions throw any exceptions. ## `bad_typeid` class bad_typeid : public exception { };Copy to clipboard The class describes an exception thrown to indicate that a [`typeid`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_typeinfo.html#typeid) operator encountered a null pointer. The value returned by `what()` is an implementation-defined [C string](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#C%20string). None of the member functions throw any exceptions. ## `type_info` class type_info { public: virtual ~type_info(); bool operator==(const type_info& right) const; bool operator!=(const type_info& right) const; bool before(const type_info& right) const; const char *name() const; private: type_info(const type_info& right); type_info& operator=(const type_info& right); };Copy to clipboard The class describes type information generated within the program by the implementation. Objects of this class effectively store a pointer to a **name** for the type, and an encoded value suitable for comparing two types for equality or **collating order**. The names, encoded values, and collating order for types are all unspecified and may differ between program executions. An expression of the form `typeid Ty` is the *only* way to construct a (temporary) `typeinfo` object. The class has only a private copy constructor. Since the assignment operator is also private, you cannot copy or assign objects of class `typeinfo` either. ### `type_info::operator!=` bool operator!=(const type_info& right) const;Copy to clipboard The function returns `!(*this == right)`. ### `type_info::operator==` bool operator==(const type_info& right) const;Copy to clipboard The function returns a nonzero value if `*this` and `right` represent the same type. ### `type_info::before` bool before(const type_info& right) const;Copy to clipboard The function returns a nonzero value if `*this` precedes `right` in the [collating order](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_typeinfo.html#collating%20order%20for%20types) for types. ### `type_info::name` const char *name() const;Copy to clipboard The function returns a [C string](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_over.html#C%20string) which specifies the [name](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_typeinfo.html#names%20for%20types) of the type. * * * See also the **[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#Table%20of%20Contents)** and the **[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_cpp_index.html)**. *[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_pjp.html) © 1992-2006by P.J. Plauger. All rights reserved.* Last Published: Oct 06, 2026 Previous Topic Next Topic