Update List.hpp

main
p68710245 1 year ago
parent e7c443d5a6
commit 70c9fb5205

@ -41,7 +41,7 @@ template <typename T>
void List<T>::clear() void List<T>::clear()
{ {
while (head->link) while (head->link)
head->remove_after(); delete head->remove_after();
tail = head; // 务必注意本类当中的操作是否会影响tail tail = head; // 务必注意本类当中的操作是否会影响tail
} }
@ -73,7 +73,8 @@ void List<T>::print() const
Node<T> *tempP{head->link}; Node<T> *tempP{head->link};
while (tempP) while (tempP)
{ {
tempP->print(); //tempP->print();
std::cout << tempP->get_info() << '\t';
tempP = tempP->link; tempP = tempP->link;
} }
std::cout << '\n'; std::cout << '\n';

Loading…
Cancel
Save