diff --git a/List.hpp b/List.hpp index 58e3b60..89ec106 100644 --- a/List.hpp +++ b/List.hpp @@ -41,7 +41,7 @@ template void List::clear() { while (head->link) - head->remove_after(); + delete head->remove_after(); tail = head; // 务必注意本类当中的操作是否会影响tail } @@ -73,7 +73,8 @@ void List::print() const Node *tempP{head->link}; while (tempP) { - tempP->print(); + //tempP->print(); + std::cout << tempP->get_info() << '\t'; tempP = tempP->link; } std::cout << '\n'; @@ -97,7 +98,7 @@ void List::insert_rear(Node *p) template Node *List::delete_node(Node *p) { - Node *tempP{head}; // 注意与之前的不同 + Node *tempP{head}; // 注意与之前的不同 while (tempP->link && tempP->link != p) // 找到p的位置 tempP = tempP->link; if (p == tail)