我有我的自定义异常类从boost::property_tree::ptree_bad_data推导如下:没有匹配函数调用“的boost :: property_tree :: ptree_bad_data :: ptree_bad_data()
class MyCustomException : public boost::property_tree::ptree_bad_data
{
public:
explicit MyCustomException(const std::string& msg): mMsg(msg) {}
virtual ~MyCustomException() throw() {}
virtual const char* what() const throw() { return mMsg.c_str(); }
private:
std::string mMsg;
};
在编译过程中我得到的错误是:
error: no matching function for call to ‘boost::property_tree::ptree_bad_data::ptree_bad_data()’ explicit MyCustomException(const std::string& msg): mMsg(msg) {} ^ note: candidate expects 2 arguments, 0 provided explicit MyCustomException(const std::string& msg): mMsg(msg) {} ^
任何想法可能是什么原因?
您显示的代码和错误消息不匹配。发布有关构建错误的问题时,请使用您向我们展示的[最小,完整和可验证示例](http://stackoverflow.com/help/mcve)中的错误。 –
@Someprogrammerdude我编辑了错误。 – astre
ptree_bad_data没有默认ctor,因此是错误。初始化您的基地 –