std::bad_typeid - cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Definido no cabeçalho <typeinfo> |
||
|
|
||
Uma excepção deste tipo é lançada quando um operador
typeidé aplicada para um valor nulo dereferenced ponteiro ou um tipo polimórfico.
Original:
An exception of this type is thrown when a
typeidoperator 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.
Inheritance diagram
Funções de membro
constrói um objeto Original: constructs a new The text has been machine-translated via Google Translate. (função pública membro) | |
Herdado de std::exception
Member functions
destrói o objeto de exceção Original: destructs the exception object The text has been machine-translated via Google Translate. (of std::exception função pública virtual membro) [edit]
| |
retorna uma cadeia explicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. (of std::exception função pública virtual membro) [edit]
| |
Exemplo
#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'; } }
Saída:
Attempted a typeid of NULL pointer!