I want to write a function that returns an ostream?

W B

New member
so for example I could have in my program:

cout << "Thank you. " << message() << "yada yada yada " << endl;

so far what i have won't compile.

ostream message(ostream & ostr)
{
ostr << "Hello!! " << " " << endl;
return ostr;
}

I get first the message that std::ios_base::ios_base(const std::ios_bse&)' is private.

ok then as a quick cheat i edited the ios_base.h file to make that particular line public, but then i get this error message: undefined reference to 'std::ios_base::ios_base(std::ios_base const&)'

i would think it would be really simple since its fairly simple to overload << operators in a class.

What should I do differently?
oh yeah my post should have read:
cout << message(cout) << endl;
 
Back
Top