【发布时间】:2015-03-23 23:50:57
【问题描述】:
所以我正在使用“异常”库的继承创建一个异常,但我收到一个错误,上面写着“虚拟”的抛出更宽松。
#include <string>
#include <exception>
#include <sstream>
namespace Vehicle_Renting{
using namespace std;
class Auto_Rent_Exception : public std::exception{
protected:
string error;
public:
Auto_Rent_Exception(){
}
virtual const string what() = 0;
virtual Auto_Rent_Exception* clone() = 0;
};
它说:错误:'virtual Vehicle_Renting::Auto_Rent_Exception::~Auto_Rent_Exception()' 的更宽松的抛出说明符 Vehicle_Renting 是我项目的命名空间。
【问题讨论】:
-
我们是否应该重新开始,看看谁先猜出您使用的工具链和语言版本?
-
我正在使用 Code Blocks 编译器和 c99 标准。
-
c99 ?嗯.. 这是 C++ 代码,对吧? CodeBlocks 不是编译器,它是 IDE。你用的是什么编译器?克++?铿锵++,明威?什么版本?在上面代码中的哪个 specific 行上出现了这个错误? (用评论标记它)。事实上,一个可重现的案例会很有帮助,(works here)。
-
哦,对不起,我的意思是 mingw 版本 4.4.1
-
准确的错误信息怎么样?
标签: c++ oop exception inheritance virtual