I'm trying to implement a manipulator for my stream
class. I don't know much about manipulators, but I think I'm doing everything right. The relevant parts of the code are below:
class stream
{
public:
stream& operator<<(bool b) { // send bool value and return *this; }
stream& operator<<(const char str[]) { // send string and return *this }
};
inline stream& endl(stream& s)
{
return s << "\r\n";
}
class stream stream;
int main()
{
stream << endl;
}
I don't know what I'm doing wrong, but instead of calling endl
the compiler is calling stream::operator<<(bool)
. Any idea?