You have 450 lines of code! I suggest you try to tackle this problem step by step.
1. change your Node class so that it has a *prev of class Node
2. Implement constructor() everything is same except set start.prev to null.
3. implement add node(Node *currentNode, Node *nodeToBeInserted) here you need to
a: nodeToBeInserted->next=currentNode->next
b: nodeToBeInserted->prev=currentNode
c: currentNode->next=nodeToBeInserted
4. for delete node( *currNode, nodeToDel)
a.currNode->next=nodeToDel->next;
b.because you are passing in nodeToDel as an object, it'll go out of scope, but I think this causes memory leaks, so you probably should call destructor on the nodeToDel
Good luck!
geojia
Junior Poster in Training
78 posts since May 2010
Reputation Points: 14
Solved Threads: 12
Here is a really good tutorial by Naru on linked list:
http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx
But right now I'm not seeing any linking structure in your student strut definition. As in you need a pointer to a student struct named next and another one named previous.
studentNode *next;
studentNode *prev;
Normally this is done with a Class and you point to objects of the same class. But it should be achievable with a struct.
geojia
Junior Poster in Training
78 posts since May 2010
Reputation Points: 14
Solved Threads: 12
You should be able to see if it's working. For instance when you run the program after it calls the insert() and see if it prints all your couts. I do see some problem right now. Currently you are using a double pointer container to represent your linked list. And then you are making pointer node objects. But you are making objects.
StudentPtr newPtr;
StudentPtr previousPtr;
StudentPtr nextPtr;
StudentPtr currentPtr;
to make them pointers do
StudentPtr *previousPtr;
For this program since you are not creating linked lists dynamically you don't need to have a double pointer, a single pointer pointed to the start of the list is enough.
geojia
Junior Poster in Training
78 posts since May 2010
Reputation Points: 14
Solved Threads: 12