Was wondering if soemone could point me in the right direction with the insertafter function in a double linked list. The function looks like this.
const LinkedList::Iterator LinkedList::InsertAfter(const Iterator& Iter, const ItemType& Item)
{
nodePtr nNode = new Node(Item, NULL, NULL);
// test if allocation was successful
if (nNode != NULL)
{
// was successful
// add the node to the linked list
nNode->next = tail->next;
tail->next = NewNode(ItemType(), NULL, NULL);
// set the tail to the new node
}
return(nNode);
} // Inserts a new node after the one pointed to by Iter. Returns
// a reference to this new node.
I'm not looking for an answer. I want to solve it myself, but I've been stuck rewriting this code for a couple of hours. When it compiles it just returns the tail. This is my closest attempt at getting it. The tail is suppose to be a dummy node.