0
我有一个HashTable模板类,我无法删除动态数组。 (SLList =单链表)删除动态内存
我的数据成员是:
SLList<Type>* m_ht;
unsigned int(*m_hFunction) (const Type &v);
unsigned int m_numOfBuckets;
在我的构造函数/赋值运算符,我有 '新' 分配动态内存:
m_ht = new SLList<Type>[numOfBuckets];
我的析构函数:
m_ht = nullptr;
for (size_t i = 0; i < m_numOfBuckets; ++i) // idk if this for loop
delete m_ht[i]; // is correct
delete[] m_ht;
关闭程序并跟踪内存泄漏后, g这两个'm_ht =新...',我不知道如何正确删除它们。
谢谢!