自定义异常类_1
1、
// https://www.cnblogs.com/crazyacking/p/4951638.html #include <iostream.h> #include <windows.h> class ExceptionClass1 { char* name; public: ExceptionClass1(const char* name="default name") { cout<<"Construct "<<name<<endl; this->name = (char*)name; } ~ExceptionClass1() { cout<<"Destruct "<<name<<endl; } static void mythrow() { throw ExceptionClass1("my throw"); } }; //* void main() { //ExceptionClass e("Test"); try { ExceptionClass1::mythrow(); //e.mythrow(); } catch(...) { cout<<"*********"<<endl; } } //*/ /* void main() { ExceptionClass e("Test"); __try { e.mythrow(); } __except (EXCEPTION_EXECUTE_HANDLER) { cout<<"*********"<<endl; } } //*/
2、
3、
4、
5、