#ifndef OSTREAM_ITERATOR_INTH #define OSTREAM_ITERATOR_INTH #include #include using namespace std; class ostream_iterator_int: public iterator { ostream *ost; class proxy { ostream *const ost; public: proxy(ostream *initial_ost): ost(initial_ost) {} void operator=(int i) const {*ost << i << "\n";} }; public: ostream_iterator_int(ostream& initial_ost): ost(&initial_ost) {} const proxy operator*() const {return ost;} //means return proxy(ost); ostream_iterator_int& operator++() {return *this;} }; inline const ostream_iterator_int operator++(ostream_iterator_int& it, int) { const ostream_iterator_int old = it; ++it; return old; } #endif