【发布时间】:2015-09-05 13:04:00
【问题描述】:
我为我的库定义了一个小的异常层次结构。它继承自std::runtime_error,像这样:
class library_exception : public std::runtime_error {
using std::runtime_error::runtime_error;
};
class specific_exception : public library_exception {
int guilty_object_id;
specific_exception(int guilty_object_id_)
: guilty_object_id(guilty_object_id_) {}
};
编译器说:
错误:调用 'library_exception' 的隐式删除的默认构造函数
并指向 specific_exception 构造函数。
为什么要在这里调用默认构造函数?
【问题讨论】: