读书人

External exception EEFFACE有关问题

发布时间: 2013-03-17 13:48:31 作者: rapoo

External exception EEFFACE问题
一个异常问题。。不知道为什么会抛出exception EEFFACE?请教大家。。。


void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
int x;
try
{
x = Edit1->Text.ToInt();
if (x == 1)
{
throw new MyException("抛出啦");
}
}
catch(MyException &myException)
{
ShowMessage(myException.test);
}
}



class MyException
{
public:
String test;
MyException(String Message)
{
test = Message;
}

};





[解决办法]
上代码,不解释。
class MyException: public Exception
{
public:
String test;
MyException(String strMessage): Exception(strMessage)
{
test = strMessage;
}
};


void __fastcall TForm1::Button1Click(TObject *Sender)
{
int x;
try
{
x = Edit1->Text.ToInt();
if (x == 1)
{
throw MyException("抛出啦");
}
}
catch (MyException &myException)
{
ShowMessage(myException.test);
}
}

读书人网 >C++ Builder

热点推荐