c++ 重新抛出异常

xiaoxiao2021-02-27  425

//Rethrowing 实质还是异常的嵌套

#include<iostream>

using namespace std; int main() { try { try { exception e("It's my error"); cout << "I'm trying" << endl; throw e; } catch (exception &e) { cout << "I'm First Exception but I can't handle it" << endl; //可改变异常的状态//正是c++ primer 中所提及的 throw; } } catch (exception &e) { cout << "I'm Second Exception if you can't handle it let me handle it" << endl; } system("pause"); return 0; }
转载请注明原文地址: https://www.6miu.com/read-3490.html

最新回复(0)