Is divided into bad_cast
: a pointer means, such as plastic or the like transfer data type conversion exception
bad_alloc
: refers to an aberrant memory allocated time
bad_typeid
: null pointer exception of
example:
using namespace std;
int main()
{
try
{
int iy = 1920909109030139 * 2902930290329;
int* id_ = new int[iy];
}
catch (bad_cast &) //转换异常
{
cout << "转换异常" << endl;
}
catch (bad_alloc &) //内存分配异常
{
cout << "内存异常" << endl;
}
catch (bad_typeid &)
{
cout << "空指针异常" << endl;
}
std::cout << "Hello World!\n";
}
- operation result: