扩展ostringstream错误C ++

时间:2012-08-08 13:17:50

标签: c++

为了简化问题,我在StringStream文件中写了这个课程Notifications.h

namespace A {
namespace B {
namespace C {

extern std::locale g_classicLocale;
class StringStream : public virtual std::ostringstream
{
 public:
        StringStream() { imbue(g_classicLocale); }
        virtual ~StringStream() {};
};

} // namespace C
} // namespace B
} // namespace A

现在,我正在尝试在StringStream文件中使用DBNotification.cpp

 #include "Notifications.h"

 namespace A{
 namespace B{
 namespace C{

         DBNotification::DBNotification(){

         }
         DBNotification::~DBNotification(){

         }
         StringStream DBNotification::getValues(){

            // do some work and return me a StringStream Object
         }
 } // C
 } // B
 } // A

当我构建源代码时,我得到:

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/ios_base.h: In copy constructor 'std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/ios_base.h:779: error: 'std::ios_base::ios_base(const std::ios_base&)' is private
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:55: error: within this context
../Notifications.h: In copy constructor 'A::B::C::StringStream::StringStream(const A::B::C::StringStream&)':
../Notifications.h:49: note: synthesized method 'std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)' first required here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/streambuf: In copy constructor 'std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::basic_stringbuf(const std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >&)':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/streambuf:781: error: 'std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits = std::char_traits<char>]' is private
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:71: error: within this context
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd: In copy constructor 'std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(const std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >&)':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:79: note: synthesized method 'std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::basic_stringbuf(const std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >&)' first required here

有人能让我知道发生了什么吗?

1 个答案:

答案 0 :(得分:3)

通常无法复制流。您的函数DBNotification::getValues()返回一个流对象。

请参阅this answer