有一种方法可以处理异常,然后转到引发异常的代码中的下一行?
例子:
try {
cout << "Test Begin! 1... 2... 3..." << endl;
throw "A text!";
throw 1;
throw 2;
throw 3;
cout << "Yeah! Successful!!" << endl;
} catch (char* text) {
cout << ch << endl;
???(); //Go back to the previous line
}
catch (int i) {
cout << "Thrown " << i << endl;
???(); //Go back to the previous line
}
输出将是:
Test Begin! 1... 2... 3...
A text!
Thrown 1
Thrown 2
Thrown 3
Yeah! Successful!!