#include <iostream> using namespace std; class CException { /********** Begin **********/ /********** End ***********/ }; void fn1() { throw CException(); } int main() { try { fn1(); } catch (CException& ce) { ce.Reason(); } return 0; }填写代码
时间: 2023-06-29 21:09:40 浏览: 64
#include <iostream>
代码如下:
```c++
#include <iostream>
using namespace std;
class CException {
public:
void Reason() {
cout << "Exception caught!" << endl;
}
};
void fn1() {
throw CException();
}
int main() {
try {
fn1();
} catch (CException& ce) {
ce.Reason();
}
return 0;
}
```
阅读全文