diff --git a/codes/cpp/chapter_stack_and_queue/linkedlist_deque.cpp b/codes/cpp/chapter_stack_and_queue/linkedlist_deque.cpp index d9cc953ed..35ec90ab8 100644 --- a/codes/cpp/chapter_stack_and_queue/linkedlist_deque.cpp +++ b/codes/cpp/chapter_stack_and_queue/linkedlist_deque.cpp @@ -92,8 +92,8 @@ class LinkedListDeque { if (fNext != nullptr) { fNext->prev = nullptr; front->next = nullptr; - delete front; } + delete front; front = fNext; // 更新头节点 // 队尾出队操作 } else { @@ -103,8 +103,8 @@ class LinkedListDeque { if (rPrev != nullptr) { rPrev->next = nullptr; rear->prev = nullptr; - delete rear; } + delete rear; rear = rPrev; // 更新尾节点 } queSize--; // 更新队列长度