我定义了一个异常的类:
#ifndef CIniexception_H
#define CIniexception_H
#include <exception>
using namespace std;
class CIniexception:public exception
{
private:
char *ErrorMsg;
public:
CIniexception(char *EMsg)
{
strcpy(ErrorMsg,EMsg);
}
const char *what() const throw()
{
return ErrorMsg;
}
~CIniexception()
{
exception::~exception();
}
};
#endif
在如下的地方throw出来,可是出错了:
if(!filefind.FindFile(filename))
throw CIniexception("没有找到文件");
我在调用此函数的函数上捕获了的呀可是就是出错!用的是VC6,Y??>??
你的指针没有动态分配内存就使用了。
strcpy(ErrorMsg,EMsg);这一句错误