我有我的自定義異常類從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,因此是錯誤。初始化您的基地 –