I am trying to create a Doubly Linked List and respective node class and am having an issue trying to add the data types of head and tail to my IntDLList class. I'm not quite sure what I missed, but an error is occurring stating that both head and tail were not declared, and that my Node class does not take a type. Any help is appreciated!
Edit: This does not seem to be a duplicate question, I looked at the other answers and trying to resolve an invalid use of incomplete type did not solve the same issue as my name type error.
IntDLList
using namespace std;
template <class T>
class IntDLList {
public:
IntDLList() {
head=tail=0; // error: 'head' was not declared in this scope (& same for tail)
}
~IntDLList();
int isEmpty() {
return head==0; // error: 'head' was not declared in this scope
}
void addToDLLHead(const T&);
void addToDLLTail(const T&);
T deleteFromDLLHead();
T deleteFromDLLTail();
void deleteDLLNode(const T&);
bool isInList(const T&) const;
void showList();
private:
IntDLLNode<T> *head, *tail; //error: IntDLLNode does not name a type
};
IntDLLNode
using namespace std;
template<class T>
class IntDLLNode {
friend class IntDLList;
public:
IntDLLNode() {next = prev = 0;}
IntDLLNode(const T& el, IntDLLNode *n = 0, IntDLLNode *p = 0) {
info = el;
next = n;
prev = p;
}
protected:
T info;
IntDLLNode<T> *next,*prev;
private:
};