This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
programming:cpp:exception [2022/05/05 07:26] odagawa created |
programming:cpp:exception [2022/05/05 11:09] (current) odagawa |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| =====例外処理===== | =====例外処理===== | ||
| + | |||
| + | try-catch 文を用いることでプログラムのどこでエラーが起こっているかをスムーズに把握することができる.\\ | ||
| + | '' | ||
| + | 例外クラスは '' | ||
| STL で用意されている例外クラスは以下の通り | STL で用意されている例外クラスは以下の通り | ||
| Line 10: | Line 14: | ||
| | std:: | | std:: | ||
| | std:: | | std:: | ||
| + | |||
| + | <code cpp> | ||
| + | int main (int argc, char *argv[]) { | ||
| + | |||
| + | try { | ||
| + | |||
| + | if (/ | ||
| + | throw std:: | ||
| + | |||
| + | } catch ( const std:: | ||
| + | std::cerr << error.what() << std::endl; | ||
| + | std:: | ||
| + | } catch ( const std:: | ||
| + | std::cerr << error.what() << std::endl; | ||
| + | std:: | ||
| + | } | ||
| + | |||
| + | std:: | ||
| + | |||
| + | } | ||
| + | </ | ||