Add destructors to the C++ codes.

This commit is contained in:
Yudong Jin
2023-01-14 19:52:11 +08:00
parent 87acfc91ab
commit bb657f9517
19 changed files with 121 additions and 24 deletions

View File

@ -330,6 +330,10 @@ comments: true
rear = nullptr;
queSize = 0;
}
~LinkedListQueue() {
delete front;
delete rear;
}
/* 获取队列的长度 */
int size() {
return queSize;
@ -784,6 +788,9 @@ comments: true
cap = capacity;
nums = new int[capacity];
}
~ArrayQueue() {
delete[] nums;
}
/* 获取队列的容量 */
int capacity() {
return cap;

View File

@ -324,6 +324,9 @@ comments: true
stackTop = nullptr;
stkSize = 0;
}
~LinkedListStack() {
freeMemoryLinkedList(stackTop);
}
/* 获取栈的长度 */
int size() {
return stkSize;