exp_unex.cpp

来自「c c++最佳编程 1000 多个小技巧 源码」· C++ 代码 · 共 30 行

CPP
30
字号
#include <iostream.h>

void XHandler(int test)
 {
   try 
   {
      if(test==0) throw test;
      if(test==1) throw 'a';
      if(test==2) throw 123.23;
    }
   catch(int i)
    {
      cout << "Caught an integer." << endl;
    }
   catch(...)
    {
      cout << "Caught one." << endl;
    }
 }

void main(void)
 {
   cout << "Start: " << endl;
   XHandler(0);
   XHandler(1);
   XHandler(2);
   cout << "End";
 }
 

⌨️ 快捷键说明

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