??C++ ????????????????
???????????? ???????[ 2014/9/11 11:05:03 ] ??????????????? C++ ??????
??????????????????μ??????????????????C++????????
??????VC++?У??ж?????????????????????
????No exception handling (????????)
????C++ only ??C++???????????
????C++ ??SEH ??C++?????windows ????????????
???????????????????????????????????????????????????C++???????????????????????????????
// simple class
class MyAppObject
{
public:
MyAppObject(int id) : _myID(id) {}
~MyAppObject();
int _myID;
void DoSomething(int throwWhat) ;
};
// can throw 2 different exception
void MyAppObject::DoSomething(int throwWhat)
{
printf("MyAppObject::DoSomething called for '%d'
"?? _myID);
switch (throwWhat)
{
case 0:
break;
case 1:
this->_myID /= 0; // exception 1
break;
case 2:
throw SimpleString("error!"); // exception 2
break;
}
}
// Test exception for the above class
void TestMyAppObject()
{
printf("before try”);
try // line1
{
printf("in try”);
MyAppObject so = 1; // line2
SimpleString ss("test ex point one"); // line3
so.DoSomething(1); // line4
printf("so::ID called for '%d'
"?? so._myID);
MyAppObject so2 = 2; // line5
printf("so2::ID called for '%d'
"?? so2._myID);
so2.DoSomething(0); // line6
}
catch(const SimpleString &e) // line7
{
//printf("something happened: %s
"?? e);
}
catch(...) //line8
{
//printf("something happened: %s
"?? "SEH");
}
}
????????????????????“no exception”??????????line1??line7??line8??????????size???
????Exe
????Obj
????32??256 bytes
????20??931 bytes
??????????line4???????“??0”??????????????????????????????????????????????????????????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11