diff --git a/chapter_stack_and_queue/deque.md b/chapter_stack_and_queue/deque.md index e26d2160e..74438bf85 100644 --- a/chapter_stack_and_queue/deque.md +++ b/chapter_stack_and_queue/deque.md @@ -470,7 +470,7 @@ comments: true /* 析构方法 */ ~LinkedListDeque() { - // 释放内存 + // 遍历链表删除结点,释放内存 DoublyListNode *pre, *cur = front; while (cur != nullptr) { pre = cur; diff --git a/chapter_stack_and_queue/queue.md b/chapter_stack_and_queue/queue.md index b06eef8e2..7f09f6508 100755 --- a/chapter_stack_and_queue/queue.md +++ b/chapter_stack_and_queue/queue.md @@ -362,8 +362,8 @@ comments: true } ~LinkedListQueue() { - delete front; - delete rear; + // 遍历链表删除结点,释放内存 + freeMemoryLinkedList(front); } /* 获取队列的长度 */ diff --git a/chapter_stack_and_queue/stack.md b/chapter_stack_and_queue/stack.md index 346ceb3ec..b18d58726 100755 --- a/chapter_stack_and_queue/stack.md +++ b/chapter_stack_and_queue/stack.md @@ -353,6 +353,7 @@ comments: true } ~LinkedListStack() { + // 遍历链表删除结点,释放内存 freeMemoryLinkedList(stackTop); }