Extend the function eraseValue() to erase all occurrences of "target" in the linked list.
template < typename T >
void eraseAll (node * & front, const T& target);
This is the implementation of eraseValue() that must be modified.
{
node< T > *curr = front, *prev = NULL;
bool foundItem = false;
while (curr != NULL && !foundItem )
{
if (curr->nodeValue == target)
{
if (prev == NULL)
{
front = front -> next;
}
else
{
prev->next = curr-> next;
delete curr;
foundItem = true;
}
}
else
{
prev = curr;
curr = curr-> next;
}
}