0

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.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sid78669
0

Well, I have ended up rewriting the whole class, specialized, inside the .h file itself.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.