从std :: streambuf继承时不兼容的析构函数编译器警告

时间:2014-03-01 19:24:08

标签: c++ iostream icc streambuf

当继承自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;
        }
}

1 个答案:

答案 0 :(得分:2)

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

~CAbcBuffer() throw() {
    delete [] buffer;
}