I have to write a deque class using a doubly-linked list. I'm trying to add a node with a value into the list and this is the code I have for the insert that I have currently.
Code:
Node *prev = Head->Succ;
newptr = new (nothrow) Node;
newptr->Item = Item;
newptr->pred = prev;
newptr->succ = prev->Next;
prev->succ->pred = newptr;
prev->next = newptr;
Also, my constructor looks like this...
Code:
template <typename EType>
Deque<EType>::Deque(){
Num = 0;
Head = new (nothrow) Node;
Tail = new (nothrow) Node;
Head->Succ = NULL;
Head->Pred = NULL;
Tail->Succ = NULL;
Tail->Pred = NULL;
};
My destructor doesn't have anything too it right now. When I compile, I get 3 unresolved external errors, one regarding the constructor, one the destructor, and one the function called put_front which is the section I am asking about and I'm not really sure why. My driver file I'm using to test this looks like this...
Code:
int main(){
bool flag;
int Item;
Deque<int> A;
Item = 10;
flag = A.put_front(Item);
cout << flag << endl;
return 0;
}
First of all, this list uses a dummy node. So, I believe this will work if there are already some nodes containing values stored in the list after the dummy node, however I am not sure how to implement something like this in an empty list. I'm still really shaky with whats going on with these lists so any explanation would be great.