std::bad_typeid
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <typeinfo>
|
||
| class bad_typeid : public std::exception; |
||
Una excepción de este tipo se produce cuando un operador typeid se aplica a un valor nulo puntero sin referencia o un tipo polimórfico .
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.
Contenido |
[editar] Las funciones miembro
| construye un objeto bad_typeid nuevoOriginal: 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. (miembro público función) | |
Inherited from std::exception
Member functions
| [virtual] |
destructs el objeto de excepción Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Virtual Member público of std::exception función)
|
| [virtual] |
devuelve una cadena explicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Virtual Member público of std::exception función)
|
[editar] Ejemplo
#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!
