diff --git a/codes/cpp/chapter_heap/my_heap.cpp b/codes/cpp/chapter_heap/my_heap.cpp index 56a8756a3..56ac3f47c 100644 --- a/codes/cpp/chapter_heap/my_heap.cpp +++ b/codes/cpp/chapter_heap/my_heap.cpp @@ -120,6 +120,7 @@ public: cout << "堆的树状表示:" << endl; TreeNode *root = vecToTree(maxHeap); PrintUtil::printTree(root); + freeMemoryTree(root); } }; diff --git a/codes/cpp/include/PrintUtil.hpp b/codes/cpp/include/PrintUtil.hpp index 053b9c030..e54926251 100644 --- a/codes/cpp/include/PrintUtil.hpp +++ b/codes/cpp/include/PrintUtil.hpp @@ -331,5 +331,6 @@ class PrintUtil { cout << "堆的树状表示:" << endl; TreeNode *root = vecToTree(vec); printTree(root); + freeMemoryTree(root); } };