ios_base.h 中的 C++ 错误

标签 c++ gcc

/usr/include/c++/4.4/bits/ios_base.h: In member function ‘std::basic_ios >& std::basic_ios >::operator=(const std::basic_ios >&)’:
/usr/include/c++/4.4/bits/ios_base.h:793: error: ‘std::ios_base& std::ios_base::operator=(const std::ios_base&)’ is private
/usr/include/c++/4.4/iosfwd:47: error: within this context
/usr/include/c++/4.4/iosfwd: In member function ‘std::basic_ostream >& std::basic_ostream >::operator=(const std::basic_ostream >&)’:
/usr/include/c++/4.4/iosfwd:56: note: synthesized method ‘std::basic_ios >& std::basic_ios >::operator=(const std::basic_ios >&)’ first required here
/usr/include/c++/4.4/iosfwd: In member function ‘std::basic_ofstream >& std::basic_ofstream >::operator=(const std::basic_ofstream >&)’:
/usr/include/c++/4.4/iosfwd:84: note: synthesized method ‘std::basic_ostream >& std::basic_ostream >::operator=(const std::basic_ostream >&)’ first required here
/usr/include/c++/4.4/streambuf: In member function ‘std::basic_filebuf >& std::basic_filebuf >::operator=(const std::basic_filebuf >&)’:
/usr/include/c++/4.4/streambuf:778: error: ‘std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits = std::char_traits]’ is private
/usr/include/c++/4.4/iosfwd:78: error: within this context
/usr/include/c++/4.4/iosfwd: In member function ‘std::basic_ofstream >& std::basic_ofstream >::operator=(const std::basic_ofstream >&)’:
/usr/include/c++/4.4/iosfwd:84: note: synthesized method ‘std::basic_filebuf >& std::basic_filebuf >::operator=(const std::basic_filebuf >&)’ first required here

有人知道这个错误是关于什么的吗?

更新:来自以下行:

ofstream myOutStream = ofstream(myCurrentLogName.c_str(), ios::app);

最佳答案

您正在尝试复制或分配流(std::istreamstd::ostream 的后代)。然而,流不能被复制或分配。

编辑

将您的代码更改为:

std::ofstream myOutStream(myCurrentLogName.c_str(), std::ios::app);

关于ios_base.h 中的 C++ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3354230/

相关文章:

c++ - 构造函数定义中的 void 是什么意思?

c++ - 为什么返回局部变量或临时地址只是警告而不是错误?

c++ - SQLite 是否使用 SQLCipher 扩展泄漏内存?

C - 字符串给我错误

c++ - 为什么虚拟析构函数写入内存?

c++ - 如何避免成员回调和 shared_ptr 的循环引用?

c++ - 我在多重映射中两次获得相同的 key ,它只存在于文本文件中。

从 gcc 的中间文件编译目标文件

c++ - 当函数没有显式返回值时如何强制编译器错误

java - 32 位 DLL 导致 UnsatisfiedLinkError