Skip to content

Commit

Permalink
bad_array_new_length : サンプルコードを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
faithandbrave committed Oct 16, 2024
1 parent 7a4c6c5 commit ab36172
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions reference/new/bad_array_new_length.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ namespace std {
動的に記憶域を確保しようとする配列の長さが 0 未満または処理系の最大値以上の場合に送出される例外。
## 例
```cpp example
#include <iostream>
int main() {
int n = -1;
try {
int* p = new int[n];
delete[] p;
}
catch (std::bad_array_new_length&) {
std::cout << "bad array new length" << std::endl;
}
}
```

### 出力例
```
bad array new length
```

## バージョン
C++11

### 処理系
- [Clang](/implementation.md#clang): 7 [mark verified]
- [GCC](/implementation.md#gcc): 4.9 [mark verified]
- [Visual C++](/implementation.md#visual_cpp): 2019 [mark verified]

0 comments on commit ab36172

Please sign in to comment.