I am trying to implement a LinkedList for the first time. I almost finished declaring the header file, but I'm getting this one minor error that won't go away. Where I declare the class LinkedList and Iterator below the Node class, I keep getting a message "Redefinition of LinkedList as a differnet kind of symbol" and "Redefinition of Iterator as a different kind of symbol". I tried declaring the classes at the very top of the code like below, moving the friend functions to the private declarations, but nothing seems to work. Can someone point me to what I'm doing wrong. I haven't done much else besides what is below.
class LinkedList;
class Iterator;
template <typename T>
class Node{
public:
Node(T Data);
private:
T data;
Node* next;
Node* previous;
friend class LinkedList;
friend class Iterator;
};
template<typename T>
class LinkedList {
public:
LinkedList();
void pushback(T data);
//void insert(Iterator pos, T data);
~LinkedList();
//Iterator begin();
//Iterator end();
private:
Node* first;
Node* last;
friend class Iterator;
};
template <typename T>
class Iterator{
public:
private:
Node* position;
LinkedList* container;
friend class LinkedList;
};
#endif /* defined(__Linked_List_1__LinkedList__) */