I have been working on a template class for linked list and sometimes I come across this member function:
template <class T>
bool DLList<T>::deleteData(T data)
{
ListNode<T> *temp = head;
while(temp != NULL && temp->data != data)
temp = temp->next;
if(temp == NULL)
return false;
else{
temp->previous->next = temp->next;
temp->next->previous = temp->previous;
delete temp;
return true;
}
}
Now the thing is that '!=' operator works fine with most datatype, except char * or string. In such cases I wish to utilise the strcmp function. However, I am not able to understand if I can specialize just one function or if I need to redo the whole class with char * specialization, since all other member functions seems perfectly fine.