prog17_03.cpp

来自「一本语言类编程书籍」· C++ 代码 · 共 21 行

CPP
21
字号
// Program 17.3 Throw an exception object  File: prog17_03.cpp
#include <iostream>
#include "MyTroubles.h"
using std::cout;
using std::endl;

int main() {
  for(int i = 0 ; i < 2 ; i++) {
    try     {
      if(i == 0)
        throw Trouble();
      else
        throw Trouble("Nobody knows the trouble I've seen...");
    }
    catch(const Trouble& t) {
      cout << endl << "Exception: " << t.what();
    }
  }
  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?