64,654
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <exception>
#include <iostream>
using namespace std;
void Crash(void)
{
int i = 1;
int j = 0;
try
{
i /= j;
//cout << i << endl; //cout the value
}
catch(...)
{
cout << "Abnormal in Crash" << endl;
}
//cout << i << endl;
printf("No abnormal in Crash\n");
}
int _tmain(int argc, _TCHAR* argv[])
{
int i = 1;
int j = 0;
try
{
Crash();
}
catch(float i)
{
cout << "Error FLOAT:" << i << endl;
}
catch(int i)
{
cout << "Error INT:" << i << endl;
}
catch(...)
{
cout << "Abnormal in Main" << endl;
}
cout << "No Abnormal in Main" << endl;
getchar();
return 0;
}
#include "stdafx.h"
#include <exception>
#include <iostream>
using namespace std;
void Crash(void)
{
int i = 1;
int j = 0;
try
{
i /= j;
//cout << i << endl; //cout the value
}
catch(...)
{
cout << "Abnormal in Crash" << endl;
throw ;//mark
return ;
}
//cout << i << endl;
printf("No abnormal in Crash\n");
}
int _tmain(int argc, _TCHAR* argv[])
{
int i = 1;
int j = 0;
try
{
Crash();
}
catch(float i)
{
cout << "Error FLOAT:" << i << endl;
}
catch(int i)
{
cout << "Error INT:" << i << endl;
}
catch(...)
{
cout << "Abnormal in Main" << endl;
return 0;
}
cout << "No Abnormal in Main" << endl;
getchar();
return 0;
}