I have sent you a PM. I think once you are happy with your code it could be useful to post it here, after the cutoff time for your project to be assessed of course.
If you using MS Visual Studio C++ then your problem lies with this: Code: class iterator : public std::iterator< std::bidirectional_iterator_tag,T,ptrdiff_t> It should be like this: Code: class iterator : public list<T>::iterator
This compiles and works under MS Visual Studio 2008 C++: Code: #include <iostream> #include <list> using namespace std; template<class T> class Ring { list<T> lst; public: // Forward declarations for class iterator // // Without these declarations, the Ring // class would see std::iterator instead of // its own iterator class iterator; //friend class iterator; // We can't use std::iterator "out of the box" because it doesn't // "know" how to loop back around a circular list. So we are // creating a child class based on std::iterator, then "teaching" it // how to loop back around. The main difference is in the code for // operator++ and operator--(). class iterator : public list<T>::iterator { // The "typename" construct is sometimes required in C++ // to force the compiler to recognize something as a data // type. In the line below, we are forcing the compiler to // recognize "T" as a data type. This kind of hack is // often needed when declaring template iterators. typename list<T>::iterator it; list<T>* r; public: iterator() {} iterator( list<T>& lst, const typename list<T>::iterator& i ) : r( &lst ), it( i ) {} bool operator==( const iterator& x ) const { return it == x.it; } bool operator!=( const iterator& x ) const { return !( *this == x ); } typename list<T>::reference operator*() const { return *it; } iterator& operator++() { ++it; if ( it == r->end() ) it = r->begin(); return *this; } iterator operator++( int ) { iterator tmp = *this; ++*this; return tmp; } iterator& operator--() { if ( it == r->begin() ) it = r->end(); --it; return *this; } iterator operator--( int ) { iterator tmp = *this; --*this; return tmp; } iterator insert( const T& x ) { return iterator( *r, r->insert( it, x ) ); } iterator erase() { return iterator( *r, r->erase( it ) ); } }; // The interface for Ring is fairly sparse. Note that we have not // made it possible to go to the "end" of a ring by using "end()" // since a ring has no true end. void push_back( const T& x ) { lst.push_back( x ); } iterator begin() { return iterator( lst, lst.begin() ); } int size() { return lst.size(); } }; int main() { Ring<int> r; Ring<int>::iterator it; int i; //Push test values. r.push_back(1); r.push_back(2); r.push_back(3); //Display values. it = r.begin(); for(i = 0; i < 6; i++) { cout << *it << endl; it++; } return 0; }