std::bad_typeid
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>| definiert in Header <typeinfo>
|
||
class bad_typeid : public std::exception; |
||
Eine Ausnahme von dieser Art wird ausgelöst, wenn ein typeid Betreiber einer dereferenziert Null-Zeiger-Wert oder einer polymorphen Typs angewendet wird .
Original:
An exception of this type is thrown when a typeid operator is applied to a dereferenced null pointer value or a polymorphic type.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Inheritance diagram
Member-Funktionen
baut eine neue bad_typeid ObjektOriginal: constructs a new bad_typeid objectThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) | |
Inherited from std::exception
Member functions
Beispiel
#include <iostream>
#include <typeinfo>
struct S { // The type has to be polymorphic
virtual void f();
};
int main()
{
S* p = nullptr;
try {
std::cout << typeid(*p).name() << '\n';
} catch(const std::bad_typeid& e) {
std::cout << e.what() << '\n';
}
}
Output:
Attempted a typeid of NULL pointer!
