根据cppreference.com,std::ios_base::failure有两个继承层次结构:

题
为什么和有什么区别?
背景
使用g ++ 4.7.1我遇到了这个错误,到目前为止我知道这是因为第一个继承层次结构:
错误:'const class std :: ios_base :: failure'没有名为'code'的成员
UPDATE
使用gcc,即使在C++ 11模式下ios_base::failure仍然继承exception.从这里引用:
ios_base :: failure不是从system_error派生的.
那是因为在C++ 11中引入了std :: system_error.std::ios_base::failure直接来自std::exception之前.
由于code()方法是其成员std::system_error,因此std::ios_base::failure不会在不支持C++ 11的环境中公开它.
| 归档时间: |
|
| 查看次数: |
679 次 |
| 最近记录: |