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;
		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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.