简体   繁体   English

ios_base.h中的C ++错误

[英]C++ error in ios_base.h

/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:在成员函数'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/bits/ios_base.h:793:错误:'std :: ios_base&std :: ios_base :: operator =(const std :: ios_base&)'是私有的
/usr/include/c++/4.4/iosfwd:47: error: within this context /usr/include/c++/4.4/iosfwd:47:错误:在此上下文中
/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:在成员函数'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:56:注意:这里首先需要合成方法'std :: basic_ios>&std :: basic_ios> :: operator =(const std :: basic_ios>&)'
/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:在成员函数'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/iosfwd:84:注意:这里首先需要合成方法'std :: basic_ostream>&std :: basic_ostream> :: operator =(const std :: basic_ostream>&)'
/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:在成员函数'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/streambuf:778:错误:'std :: basic_streambuf <_CharT,_Traits>&std :: basic_streambuf <_CharT,_Traits> :: operator =(const std :: basic_streambuf <_CharT,_Traits> &)[with _CharT = char,_Traits = std :: char_traits]'是私有的
/usr/include/c++/4.4/iosfwd:78: error: within this context /usr/include/c++/4.4/iosfwd:78:错误:在此上下文中
/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:在成员函数'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 /usr/include/c++/4.4/iosfwd:84:注意:这里首先需要合成方法'std :: basic_filebuf>&std :: basic_filebuf> :: operator =(const std :: basic_filebuf>&)'

anyone has any idea what is this error about? 任何人都知道这个错误是什么?

Update : it comes from the following line: 更新 :它来自以下行:

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

You are trying to copy or assign a stream (descendant of std::istream or std::ostream ). 您正在尝试复制或分配流( std::istreamstd::ostream后代)。 Streams, however, cannot be copied or assigned. 但是,无法复制或分配流。

Edit 编辑

Change your code to: 将您的代码更改为:

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

That is the first line of a two-line error message. 这是两行错误消息的第一行。 The first line gives the location of the private/protected member you're trying to access, and the second line gives the location of the attempt to access it. 第一行给出了您尝试访问的私有/受保护成员的位置,第二行给出了尝试访问它的位置。 The full message will look something like 完整的消息看起来像

header.h:53: error: `thing` is private
source.cpp:99: error: within this context

The second line will tell you where to look for the error. 第二行将告诉您在哪里查找错误。

Update 更新

That was the answer to the original question. 这是原始问题的答案。 Now we've seen the full error message and the code causing it, sbi has the answer. 现在我们已经看到完整的错误消息和导致它的代码,sbi有答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM