Hi,

I'm trying to do a vector of stringstreams so i can edit/manipulate them using vector functions as i have already done using strings.

everything was going fine using...

std::vector<std::stringstream> myVector

However i'm getting the error "cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'" on this line...

myVector.reserve( size ); //where size is unsigned int

is it an obvious mistake to use a vector of stringstreams? is it possible to use vector functions such as vector::reserve and also generate_n to push stringstreams onto the back of the vector?

thank you

A stringstream is still a stream, you can't just copy a stream as std::vector does for its elements. Try using a pointer/smart pointer if you really want a vector of stringstreams.

Try using a pointer/smart pointer if you really want a vector of stringstreams.

It works... changing it to a vector of pointers allows me to work around the fact that the copy constructor & assignment operators are declared private.

std::vector< std::stringstream * > myVector

Any more suggestions or improvements are more than welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.