【发布时间】:2012-07-30 14:51:12
【问题描述】:
根据cppreference.com,std::ios_base::failure有两个继承层次:
问题
为什么和有什么区别?
背景
使用 g++ 4.7.1 我遇到了这个错误,到目前为止我知道这是因为第一个继承层次结构:
错误:“const class std::ios_base::failure”没有名为“code”的成员
更新
使用 gcc,即使在 C++11 模式下,ios_base::failure 仍然继承自 exception。引用here:
ios_base::failure 不是从 system_error 派生的。
【问题讨论】: