#ifndef NODEH #define NODEH #include //for std::iterator and forward_iterator_tag using namespace std; struct node { int value; node *next; node(int initial_value, node *initial_next) : value(initial_value), next(initial_next) {} class iterator: public std::iterator { node *p; public: iterator(node *initial_p = 0): p(initial_p) {} int& operator*() const {return p->value;} iterator& operator++() {p = p->next; return *this;} //prefix friend bool operator==(const iterator& it1, const iterator& it2) { return it1.p == it2.p; } }; }; inline const node::iterator operator++(node::iterator& it, int) //postfix { const node::iterator old = it; ++it; return old; } inline bool operator!=(const node::iterator& it1, const node::iterator& it2) { return !(it1 == it2); //return !operator==(it1, it2); } #endif