2

我从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;
        }
}
4

1 回答 1

2

您缺少throw()析构函数的声明。这将解决问题:

~CAbcBuffer() throw() {
    delete [] buffer;
}
于 2014-03-01T19:30:46.280 回答