天天看點

exception handing (I)

Exception handing in program can connect the unexpected events to higher exections context, it's able to recover from the abnormal events better.

C++ could specify whether or a function could throw exceptions too.

void MyFunc()  throw(...) {

   throw 1;

}




throw could emit any type: string, int, class, ....

class CTest{

};

void MyFunc() {

   CDtorDemo D;

   cout<< "In MyFunc(). Throwing CTest exception./n";

   throw CTest();

}