I need help with this problem, here.
I have 2 functions: "find4update" is supposed to compare the incoming parameter "item2" to the item that is already in the linked list, and return the value of "found". And my second function "deletNode" should use that "find4update" function and delete the found item from the list. I dont know what I'm doing wrong.
Any ideas? Please?
template <class DataType>
bool List<DataType>::find4update(DataType item2){
bool found = false;
Node<DataType> *ptr = start;
while((ptr != NULL) && (!found)){
if(ptr->info == item2){
found = true;
}
ptr = ptr->next;
}
return found;
}
template <class DataType>
bool List<DataType>::deleteNode(DataType &item2){
bool found = false;
Node<DataType> *ptr = start;
found = find4update(item2);
if(found)
return found;
else{
while(ptr != NULL && ptr->info != item2){
if(ptr->info == item2){
delete ptr;
}
ptr = ptr->next;
}
}
}
Thanks!
By the way, this is just a part of my whole code. It would take a whole lot of space if posted it all :)