Assignment operator in linked list C++
问题 I'm trying to implement linked list in c++. I implement my assignment operator like this: // assignment operator template<class T> LinkedList<T>& LinkedList<T>::operator = (const LinkedList& rhs) { if (&rhs != this) { Node *tmp = head; while (tmp -> next) { head = head -> next; delete tmp; tmp = head; } tmp = rhs -> head; while (tmp) { append(tmp); tmp = tmp -> next; } } return *this; } In my main function, i use the following code to test: LinkedList<int> *lst1 = new LinkedList<int>(7);