E
enzo
hi all!
i need in my libraries a class to deal with messages.
I did:
class messenger
{
public:
messenger(const char* p, ostream& p_s) : m(p), m_stream(p_s)
{
}
string out()
{
m_s << m;
return m;
}
messenger&
operator << (const char* p)
{
m_s << p;
return *this;
}
private:
string m;
ostream& m_stream;
};
this class let me do:
int main()
{
messenger l(¨hallo world¨, cout);
l.out();
l << ¨hallo again¨;
return 1;
}
but i can't do:
l << endl;
i tried to change to :
class messenger : public ostream
but doesn't compile.
What am i doing wrong??
Thanks
i need in my libraries a class to deal with messages.
I did:
class messenger
{
public:
messenger(const char* p, ostream& p_s) : m(p), m_stream(p_s)
{
}
string out()
{
m_s << m;
return m;
}
messenger&
operator << (const char* p)
{
m_s << p;
return *this;
}
private:
string m;
ostream& m_stream;
};
this class let me do:
int main()
{
messenger l(¨hallo world¨, cout);
l.out();
l << ¨hallo again¨;
return 1;
}
but i can't do:
l << endl;
i tried to change to :
class messenger : public ostream
but doesn't compile.
What am i doing wrong??
Thanks