从 std::streambuf
继承时,我收到 ICL 编译器警告,指出析构函数不兼容,您知道我在这里做错了什么吗?使其成为虚拟析构函数也不起作用。
warning #809: exception specification for virtual function "CAbcBuffer::~CAbcBuffer" is incompatible with that of overridden function "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;
}
}
最佳答案
您缺少析构函数的 throw()
声明。这将解决问题:
~CAbcBuffer() throw() {
delete [] buffer;
}
关于c++ - 从 std::streambuf 继承时出现不兼容的析构函数编译器警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22119173/