How can I make a lists or a slist, whose last element points on the first; for example:
slist<int> L;
L.push_front(0);
L.push_front(1); // L is "{1,0}".
slist<int>::iterator it=L.begin(); //it points on 1;
it++; // it points yet on 0;
it++; // I would like that it points again on 1, the first element of L
I don`t think you can. The head points to the tail and the tail points to the next node back from the tail. as far as I know the tail never points to the head.
The question you ask is a requirement of an iterator not the internal data structure. You need to write a forward iterator (ie, you can increment it as you are doing) that sets itself to begin() any time it reaches end().
EDIT: Thinking about this a bit more... typically you make iterators so they conform to STL iterators so that your iterators can be used in the various STL algorithms. Since your iterator is essentially circular, there is no end, and so most STL algorithms will not work with your iterator, unless you do something really bizarre like make dereferencing end() move the iterator to begin() and dereference that.
jsmith i take it you know a fair bit about programming itself. All the answers you give are very much based on logic and knowledge so it seems. I like it :D - it's one thing i need to better myself at as i have a lot of written programming tests coming up heh. Not that i'm bad at it - just saying you seem very good at how you explain it ;)