mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 22:34:18 +08:00
Add destructors to the C++ codes.
This commit is contained in:
@ -21,6 +21,10 @@ public:
|
||||
nums = new int[capacity];
|
||||
}
|
||||
|
||||
~ArrayQueue() {
|
||||
delete[] nums;
|
||||
}
|
||||
|
||||
/* 获取队列的容量 */
|
||||
int capacity() {
|
||||
return cap;
|
||||
@ -117,5 +121,8 @@ int main() {
|
||||
PrintUtil::printVector(queue->toVector());
|
||||
}
|
||||
|
||||
// 释放内存
|
||||
delete queue;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user