#ifndef NODEH #define NODEH #include //for iterator_traits 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 { 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; //it.operator++(); return old; } inline bool operator!=(const node::iterator& it1, const node::iterator& it2) { return !(it1 == it2); //return !operator==(it1, it2); } namespace std { template <> struct iterator_traits { typedef forward_iterator_tag iterator_category; typedef int value_type; typedef ptrdiff_t difference_type; typedef int *pointer; typedef int& reference; }; //semicolon at end of class } //no semicolon at end of namespace #endif