bad_array_new_length
描述 (Description)
这是一个错误的数组长度的例外。
以下是std :: bad_array_new_length的声明。
class bad_array_new_length;
参数 (Parameters)
没有
返回值 (Return Value)
没有
异常 (Exceptions)
No-throw guarantee - 此成员函数永远不会抛出异常。
数据竞争 (Data races)
没有
例子 (Example)
在下面的示例中为std :: bad_array_new_length。
#include <iostream>
#include <exception>
#include <new>
int main() {
try {
int* p = new int[-1];
} catch (std::bad_array_new_length& e) {
std::cerr << "bad_array_new_length caught: " << e.what() << '\n';
} catch (std::exception& e) {
std::cerr << "some other standard exception caught: " << e.what() << '\n';
}
}
输出应该是这样的 -
It will throw an exception error