2
votes

/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

anyone has any idea what is this error about?

Update: it comes from the following line:

ofstream myOutStream = ofstream(myCurrentLogName.c_str(), ios::app);
2
Could you post the code that is causing the error. Looks like something to do with access privileges thoughJordan
looks like you are using assignment operator on something it doesn't likeJames
I don't know which part of my code causing this, all I got is what you see up there.MBZ
@MBZ: Maybe if you post your code, other people would be able to figure out which part is causing it.Jordan
@MBZ: The error must have been emitted while compiling a certain file. Can you post that file?Amardeep AC9MF

2 Answers

6
votes

You are trying to copy or assign a stream (descendant of std::istream or std::ostream). Streams, however, cannot be copied or assigned.

Edit

Change your code to:

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

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.