当继承自std::streambuf
并说析构函数不兼容时,我得到一个ICL编译器警告,任何想法我在这里做错了什么?使它成为虚拟析构函数也不起作用。
警告#809:虚函数的异常规范 “CAbcBuffer :: ~CAbcBuffer”与被覆盖的内容不兼容 函数“std :: basic_streambuf< _Elem,_Traits> ::〜basic_streambuf [with _Elem = char,_ Traits = std :: char_traits]“
class CAbcBuffer : public std::streambuf
{
protected:
/** Work buffer */
char *buffer;
public:
explicit CAbcBuffer()
{
/*
Stores the beginning pointer, the next pointer, and the end pointer for the
input buffer
*/
buffer = new char[100];
std::streambuf::setg(buffer, buffer, buffer);
}
~CAbcBuffer() {
delete [] buffer;
}
}
答案 0 :(得分:2)
您缺少析构函数的throw()
声明。这将解决问题:
~CAbcBuffer() throw() {
delete [] buffer;
}