views:

445

answers:

2
std::string str;
std::stringstream strm(str);

I get this error:

Error 11 error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' c:\program files\microsoft visual studio 9.0\vc\include\sstream 517

If I use istringstream, same happens.

Compiler: Visual C++ 2008.

+7  A: 
#include <string>
#include <sstream>

int main( int argc, char *argv[] ) {
    std::string str;
    std::stringstream strm( str );

    return 0;
}

Compiles fine with no errors/warnings for me in VS 2008. Can you post the full code?

kitchen
+2  A: 

Sounds like you are trying to copy a stream. This is not possible as the copy constructors are private.

steve
Yep. And the VC9 didn't link to the right code, I tried to do something like this:boost::archive::xml_iarchive xml(GetStream(igFilePath));where GetStream would copy a string stream.Nice catch, STL!
mannicken
@mannicken, so the code you posted was NOT the code on which you were getting that error...?! Wow -- way to go, let's select for mind-reading -- I'm amazed that somebody managed to see past your code to what was REALLY happening...
Alex Martelli
My bad (well, not my bad exactly but still). I narrowed down the problem by removing stuff that didn't cause it and made a mistake.
mannicken
@mannicken: why was this the accepted answer to the question posted? While it does solve your problem, it doesn't answer the question you originally posted.
kitchen
I second @Alex and @kitchen: @mannicken, could you please edit your original question to show an example of the actual error? As it stands, your question is not particularly informative.
jwfearn