Ok, I am about 20+ hours into this utterly confusing idea of link lists. The classes I have are listed below. I cannot for the life of me understand how I would write a reverse function. My office floor is cluttered with printouts and scribbles from trying to make this work. If someone could provide me with a tip on how I might attack this it would be greatly appreciated.
class Node
{
public:
Node(string s);
private:
string data;
Node* previous;
Node* next;
friend class List;
friend class Iterator;
};
class List
{
public:
List();
void push_back(string data);
void insert(Iterator iter, string s);
Iterator erase(Iterator iter);
Iterator begin();
Iterator end();
void remove(Iterator iter, string value, List a);
void unique(Iterator iter, string value, List a);
void reverse(Iterator iter, List a);
private:
Node* first;
Node* last;
friend class Iterator;
};
class Iterator
{
public:
Iterator();
string get() const;
void next();
void previous();
bool equals(Iterator b) const;
private:
Node* position;
List* container;
friend class List;
};