c++异常

来源:互联网 发布:洪金宝 黑社会 知乎 编辑:程序博客网 时间:2024/05/17 03:39
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>


using namespace std;


class NumberException {};


int returnNumber(int n) throw(NumberException) {
if (n == 0) {
throw NumberException();
}
return n;
}


int main() {
int n;
try {
cin >> n;
returnNumber(n);
}
catch (NumberException) {
cout << " aaaaaaaaa " << endl;
}


system("pause");


return 0;
}
原创粉丝点击