I have a class that extends ostringstream class.
Class A: public ostringstream
{
}
I want to read data of specified size and a specific offset from that object. So trying:
A a_;
a_ << data1 << data2;
string datax(a_[offset], size);
But getting a compile error at string datax statement.
error: no match for operator[] in ...
How can I copy data from object a_ for a specified offset and size? I dont want to remove data from the object a_.
NOTE: The class was designed by someone else and cannot be modified.
I believe with the code you have you could do:
which looks a bit ugly to me. Why not just use plain
std::stringstream
instead? (unless you have a strong reason to inherit fromstd::ostringstream
.