#include <iostream>
using namespace std;
double division(int a, int b)
{
if( b == 0 )
{
throw "Division by zero condition!";
}
return (a/b);
}
int main ()
{
int x = 50;
int y = 0;
double z = 0;
try {
z = division(x, y);
cout << z << endl;
}catch (const char* msg) {
cerr << msg << endl;
}
return 0;
}
http://www.runoob.com/cplusplus/cpp-exceptions-handling.html
博客提供了一个关于C++异常处理的教程链接,可通过该链接http://www.runoob.com/cplusplus/cpp-exceptions-handling.html查看相关内容。
1119

被折叠的 条评论
为什么被折叠?



