gpt4 book ai didi

ios_base.h 中的 C++ 错误

转载 作者:太空狗 更新时间:2023-10-29 23:47:53 24 4
gpt4 key购买 nike

/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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com