hey

i have this program for a singly linked list which is basically just using functions on it, and i need to convert it to a circular doubly linked list...it seems like it should be easy, but when i do what i think shud be done, it messes up on me, and either gives me error messages or basically tells me that the pointers m using dont exist...i think... lol

ive spent a lot of time on it already and i just dont understand why the derned thing won't work...

so, here's the implementation file of the unchanged and fully functional singly linked list:

(the node for the circular double linked list wud hold:

and int value;

a next pointer;

a prev pointer;

)

//************************************[font=Arial][font=Arial][font=Arial] //Implementation File (list.cpp) //***************************************** #include <iostream> #include <fstream> #include "list.h" using namespace std; List::List() { head = '\0'; } void List::showReverse(Node *pointer, fstream &out) const { if(pointer!='\0') { showReverse(pointer->next,out); out << pointer->data << endl; } } void List::insertNode(int num) { Node *newNode; Node *nodePtr; Node *previous = '\0'; newNode = new Node; newNode->data = num; if(!head) { head = newNode; newNode->next = '\0'; } else { nodePtr = head; previous = '\0'; while(nodePtr!='\0' && (nodePtr->data < num)) { previous = nodePtr; nodePtr = nodePtr->next; } if(previous == '\0') { head = newNode; newNode->next = nodePtr; } else { previous->next = newNode; newNode->next = nodePtr; } } } void List::printForward(fstream &out)const { Node *p; //to move through the list p = head; //position p pointer at head of list while(p) { out << p->data << endl; //display value p = p->next; //move to the next node } out << endl; } void List::printBackward(fstream &out)const { showReverse(head,out); out << endl; } void List::deleteNode(int num) { Node *nodePtr; Node *prevNode; if(head=='\0') return; if(head->data == num) { nodePtr = head->next; delete head; head = nodePtr; } else { nodePtr = head; while(nodePtr!='\0' && (nodePtr->data!=num)) { prevNode = nodePtr; nodePtr = nodePtr->next; } if(nodePtr) { prevNode->next = nodePtr->next; delete nodePtr; } } } void List::merge(List list1, List list2) { Node *ptr1; Node *ptr2; ptr1 = list1.head; while(ptr1!='\0') { insertNode(ptr1->data); ptr1 = ptr1->next; } ptr2 = list2.head; while(ptr2!='\0') { insertNode(ptr2->data); ptr2 = ptr2->next; } }

again, im trying to make these functions work on a circular doubly linked list...print backward would use the prev pointer and not a recursive function...i think...

thanks!!