I am trying to overload operator++ for a type I have defined. Here' s a little explanation beforehand.
I am working on a link_list class that can be used to create dynamic arrays of any type. I created a basic_link template to hold each element of the array. Each basic_link contains<T> contains a pointer to the next link, the previous link, and a variable to hold a T value. It looks something like this
template <typename T>
struct basic_link
{
T value;
basic_link<T> *previous, *next;
// Definitions of constructors and operators and such
}
I then have a basic_list template that contains two basic_list pointers to the first and last (head and tail) elements of the array and a size variable. I have two typedefs in the class. It looks a little like this
template <typename T>
class basic_list
{
typedef basic_link<T> link;
typedef link* iterator;
iterator head, tail;
size_t size;
// Further class definition
}
I am trying to make it so that iterator++ causes the iterator to become iterator->next. This is what I tried
friend const iterator& operator++ ( iterator& _iter )
{
_iter= _iter->next;
return _iter;
}
Any help you may can offer would be greatly appreciated.