I have a recursive method that traverses a linked list for a first name or last name then deletes the node from the list. This is what I have:
void game::DeleteR(string first_name, string last_name, ListNode* &node)
//throw (ContestantException)
{
/* See if we are at end of list. */
if (node == NULL)
//throw ListIndexOutOfRangeException("ListIndexOutOfRangeException: insert index out of range"); need to change this message
else if (node->item == first_name) || (node->item == last_name))
{
/*
* Check to see if current node is one
* to be deleted.
*/
if ((node->item == first_name) || (node->item == last_name))
{
ListNode *tempNextP;
/* Save the next pointer in the node. */
tempNextP = node->next;
/* Deallocate the node. */
free(node);
/*
* Return the NEW pointer to where we
* were called from. I.e., the pointer
* the previous call will use to "skip
* over" the removed node.
*/
node == tempNextP;
}
}
else DeleteR(first_name, last_name, node->next);
}
At line 16 I het a compile error " no match for 'operator==' in 'node->game::ListNode::item == first_name'". Can I not use a comparison operator?