64,676
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
int main()
{
try
{
int a, b, c;
a=1; b=0; c=a/b;
return 0;
}
catch(std::exception e)
{
cout<<e.what();
}
}
#include <stdio.h>
#include <windows.h>
#include <eh.h>
#include <iostream>
using namespace std;
class SEH_Exception:public exception
{
private:
unsigned int nSE;
public:
const char *what() const
{
return "divide by 0!";
}
};
void trans_func( unsigned int u, EXCEPTION_POINTERS* pExp )
{
cout<<"Handles Win32 exceptions (C structured exceptions) as C++ typed exceptions....."<<endl;
throw SEH_Exception();
}
int main()
{
try
{
_set_se_translator( trans_func );
int a, b, c;
a=1; b=0; c=a/b;
return 0;
}
catch(exception& e)
{
cout<<e.what()<<endl;
}
}
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
try
{
int a, b, c;
a=1; b=0; c=a/b;
return 0;
}
catch(...)
{
cout<<"exception thrown";
}
getchar();
return 0;
}
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
__try
{
int i=0;
i /= i;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
cout < < "除数为0 " < <endl;
}
}