Reputation: 6648
I get the following errors which is a slight improvement after taking weeks (very part-time) getting the errors out of my code:
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\sstream(451) : error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\ios(151) : see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_ostringstream<_Elem,_Traits,_Alloc>::basic_ostringstream(const std::basic_ostringstream<_Elem,_Traits,_Alloc> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
I am migrating from the CLI to std::
classes which I have even less experience with.
I think where it is saying "This diagnostic occurred in the compiler generated function" the function being referred to is my std::ostringstream os;
.
I use os
like as follows:
os << "Level: " << levelName << ", contains unexpected header at line " << (numMatched + 1)
<< "\nExpected:\n" << longStringHeader;
addToErrorSTDstring(os);
because std::string
concatenation took a line up with each addition.
The only way I use ostringstream
is
bool LevelParser::addToErrorSTDstring(std::ostringstream os){
which I believe ildjarn just perspicaciously identified as the problem for me.
Upvotes: 0
Views: 637
Reputation: 62975
The error indicates that you're trying to copy an instance of std::ostringstream
, but all standard streams are non-copyable objects (in C++11 they are, however, movable).
That's the root of the problem, but without seeing your actual code we can't give you concrete suggestions on how to fix it.
EDIT (in response to OP's edit):
addToErrorSTDstring
undoubtedly takes a std::ostringstream
by value, i.e. has a signature like:
T addToErrorSTDstring(std::ostringstream os);
Instead, you need to pass it by reference, i.e. change the signature to something like:
T addToErrorSTDstring(std::ostringstream const& os);
or:
T addToErrorSTDstring(std::ostringstream& os);
(depending on how you use it).
If you're new to C++, then you need to stop what you're working on and brush up on language fundamentals such as references and const-correctness.
Upvotes: 3