以下函数出现在OctoMap代码中:
class AbstractOcTreeNode {};
-> 他们声明了一个空类
AbstractOcTreeNode** children;
-> 这是在OcTreeDataNode
类头文件中声明的
template <typename T>
void OcTreeDataNode<T>::allocChildren() {
children = new AbstractOcTreeNode*[8];
for (unsigned int i=0; i<8; i++) {
children[i] = NULL;
}
}
这不会导致内存泄漏吗?不应该是:
template <typename T>
void OcTreeDataNode<T>::allocChildren() {
children = new AbstractOcTreeNode*[8];
for (unsigned int i=0; i<8; i++) {
delete children[i];
children[i] = NULL;
}
}
我错过了什么?谢谢您的帮助!