我需要我的方法抛出自定义异常 但它不断给我这个错误:
error C2059: syntax error : 'string'
C++自定义异常提示错误
我在读下面的链接,但它并没有解决我的问题:
http://msdn.microsoft.com/en-us/library/t8xe60cf%28VS.80%29.aspx
这是我的代码:
#include <exception>
#include <stdexcept>
#include <string>
#include "Log.h"
LOG_USE()
class Exception : public std::exception
{
public:
explicit Exception(std::string msg)
: message(msg)
{}
~Exception()
{}
virtual const char* what() const throw()
{
LOG_MSG(message) // write to log file
return message.c_str();
}
private:
std::string message;
};
#endif
在我的应用程序
某处我有看起来像这样的方法:
.....
....
void view::setDisplayView(ViewMode mode) throw(Exception("setDisplayView error"))
{
;
}
....
....
我在做什么错在这里?
我在32位Windows XP上使用Visual Studio 2008。
定义你的LOG_MSG/LOG_USE? – RolandXu
只是记录,我可以将其删除,并错误还是一样的,当我发表意见掷(异常(“setDisplayView错误”)),每一件事情是工作 – user63898
offtopic,但...您选择登录电子异常,只有当'什么()'被调用,而不是每次抛出? – TeaOverflow