I am attempting to templatize a few classes (LinkedListNode and LinkedList), such that
template <class T>
class LinkedListNode{
public:
T data;
LinkedListNode *next;
LinkedListNode();
};
In my LinkedList Class, I have private variables:
private:
LinkedListNode *head;
//iterator for traversing the list
LinkedListNode *current;
};
When compiling, I am getting strange errors:
./LinkedList.h:38:3: error: unknown type name 'LinkedListNode'; did you mean 'LinkedList'? LinkedListNode *head; ^~~~~~~~~~~~~~ LinkedList ./LinkedList.h:13:7: note: 'LinkedList' declared here class LinkedList{ ^ ./LinkedList.h:40:3: error: unknown type name 'LinkedListNode'; did you mean 'LinkedList'? LinkedListNode *current; ^~~~~~~~~~~~~~ LinkedList ./LinkedList.h:13:7: note: 'LinkedList' declared here class LinkedList{ ^ LinkedList.cpp:7:1: error: 'LinkedListNode' is not a class, namespace, or enumeration LinkedListNode::LinkedListNode(){ ^ ./LinkedList.h:5:7: note: 'LinkedListNode' declared here class LinkedListNode{ ^
Why am i getting these errors if it says my LinkedListNode is also being declared?