How to call operator<< on "this" in a descendant of std::stringstream?
Posted
by romkyns
on Stack Overflow
See other posts from Stack Overflow
or by romkyns
Published on 2010-06-10T09:24:51Z
Indexed on
2010/06/10
9:33 UTC
Read the original article
Hit count: 180
class mystream : public std::stringstream
{
public:
void write_something()
{
this << "something";
}
};
This results in the following two compile errors on VC++10:
error C2297: '<<' : illegal, right operand has type 'const char [10]'
error C2296: '<<' : illegal, left operand has type 'mystream *const '
Judging from the second one, this is because what this
points at can't be changed, but the << operator does (or at least is declared as if it does). Correct?
Is there some other way I can still use the <<
and >>
operators on this
?
© Stack Overflow or respective owner