From 8d8b713865fce785cc33178fa504031399b26c0a Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Sat, 11 Feb 2023 18:04:29 +0800 Subject: [PATCH] fix poll() in my_heap.cpp (#360) --- codes/cpp/chapter_heap/my_heap.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codes/cpp/chapter_heap/my_heap.cpp b/codes/cpp/chapter_heap/my_heap.cpp index 54d58f67..6a22d242 100644 --- a/codes/cpp/chapter_heap/my_heap.cpp +++ b/codes/cpp/chapter_heap/my_heap.cpp @@ -99,8 +99,7 @@ public: void poll() { // 判空处理 if (empty()) { - cout << "Error:堆为空" << endl; - return; + throw out_of_range("堆为空"); } // 交换根结点与最右叶结点(即交换首元素与尾元素) swap(maxHeap[0], maxHeap[size() - 1]);