| title |
bad_typeid Exception | Microsoft Docs |
| ms.custom |
|
| ms.date |
11/04/2016 |
| ms.reviewer |
|
| ms.suite |
|
| ms.technology |
|
| ms.tgt_pltfrm |
|
| ms.topic |
language-reference |
| f1_keywords |
|
| dev_langs |
|
| helpviewer_keywords |
bad_typeid exception |
exceptions, bad_typeid |
|
| ms.assetid |
5963ed58-4ede-4597-957d-f7bbd06299c2 |
| caps.latest.revision |
7 |
| author |
mikeblome |
| ms.author |
mblome |
| manager |
ghogen |
| translation.priority.ht |
cs-cz |
de-de |
es-es |
fr-fr |
it-it |
ja-jp |
ko-kr |
pl-pl |
pt-br |
ru-ru |
tr-tr |
zh-cn |
zh-tw |
|
The bad_typeid exception is thrown by the typeid operator when the operand for typeid is a NULL pointer.
catch (bad_typeid)
statement
Remarks
The interface for bad_typeid is:
class bad_typeid : public exception
{
public:
bad_typeid(const char * _Message = "bad typeid");
bad_typeid(const bad_typeid &);
virtual ~bad_typeid();
};
The following example shows the typeid operator throwing a bad_typeid exception.
// expre_bad_typeid.cpp
// compile with: /EHsc /GR
#include <typeinfo.h>
#include <iostream>
class A{
public:
// object for class needs vtable
// for RTTI
virtual ~A();
};
using namespace std;
int main() {
A* a = NULL;
try {
cout << typeid(*a).name() << endl; // Error condition
}
catch (bad_typeid){
cout << "Object is NULL" << endl;
}
}
Run-Time Type Information
Keywords