Never mind: I managed to work it out by going over headers,

In case anybody else should ever have the same problem:


#include <iostream>

class MyStream
{
int total;
public:
MyStream() : total (0) {}
void flush() { std::cout << total << "\n"; total = 0; }
MyStream &operator<< (int i) { total = total + i; return *this; }
MyStream &operator<< (MyStream &f(MyStream &)) { return f(*this); }
~MyStream() { flush(); }
};

MyStream &endl(MyStream &f) { f.flush(); return f; }

int main (int argc, char *argv[])
{
MyStream str;
str << 1 << 2 << 3 << endl << 4 << endl << 7;
}