Hi, I need to make a circular list, using herence from a STL normal list.
I've though that I could do it making a new function that makes the iterator move to the next position, and if it's equal to the last list node, it jumps to the beggining of the list. Is that the right way?
Anyway I've tried to make that function and I dont know how to start it.
#include <cstdlib>
#include <list>
#include <iostream>
usingnamespace std;
template<class T>
class listacirc : public list<T> {
public:
listacirc<T>.iterator *sig(listacirc<T>.iterator it);
//I dont know how to say that I want to return an iterator, and how to put that "it" is an iterator.
};
template<class T>
listacirc<T>.iterator sig(listacirc<T>.iterator it){
it++;
return it;
//It needs the other part, I'll make it later.
}
So the idea is not using i++ in the main function ,is to use it.sig();
I think iterators are a member-class, not just a member. You're going to have to implement an iterator class that extends the list::iterator class.
By the way: isn't a deque pretty much a circular list? What exactly do you want it to do? Aren't circular lists mostly just "easily add/remove at the start/end" lists? If so, that's exactly what a deque is.