#define _CRT_SECURE_NO_WARNINGS
#include
using namespace std;
class MyException{
public:
MyException(char* str){
error = new char[strlen(str)+1];
strcpy(error, str);
}
void what(){
cout << error << endl;
}
public:
char* error;
~MyException(){
if (error != NULL){
delete[] error;
}
}
};
void fun3(){
MyException my("aaaa");
throw my;
}
void test01(){
try{
fun3();
}
catch (MyException e){
e.what();
}
}
int main(void)
{
test01();
system("pause");
return 0;
}