- C 标准库
 - C 标准库
 
- C++ 标准库
 - C++ 库 - 主页
 - C++ 库 - <fstream>
 - C++ 库 - <iomanip>
 - C++ 库 - <ios>
 - C++ 库 - <iosfwd>
 - C++ 库 - <iostream>
 - C++ 库 - <istream>
 - C++ 库 - <ostream>
 - C++ 库 - <sstream>
 - C++ 库 - <streambuf>
 - C++ 库 - <原子>
 - C++ 库 - <复杂>
 - C++ 库 - <异常>
 - C++ 库 - <功能>
 - C++ 库 - <限制>
 - C++ 库 - <语言环境>
 - C++ 库 - <内存>
 - C++ 库 - <新>
 - C++ 库 - <数字>
 - C++ 库 - <正则表达式>
 - C++ 库 - <stdexcept>
 - C++ 库 - <字符串>
 - C++ 库 - <线程>
 - C++ 库 - <元组>
 - C++ 库 - <类型信息>
 - C++ 库 - <实用程序>
 - C++ 库 - <valarray>
 
C++ 新库 - bad_array_new_length
描述
这是数组长度错误的例外情况。
以下是 std::bad_array_new_length 的声明。
class bad_array_new_length;
参数
没有任何
返回值
没有任何
例外情况
无抛出保证- 该成员函数永远不会抛出异常。
数据竞赛
没有任何
例子
在下面的 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
新的.htm