It’s pretty much just like the std::list
iterator, except the end iterator is where the next pointer is the head of the list, not when it’s NULL
. A reference page will tell you what you’re supposed to implement. The underlying representation will be a pointer to a list node, operator*
will return a reference to the data, operator++
will set the pointer to next
, etc.
Alternatively, use an array implementation with modular arithmetic.
solved Need help coding iterator for a circular linked list in C++