这是 B+ 树的一个节点。我想使用智能指针,因为我的程序泄漏了大量内存。如何使用智能指针转换代码?
class node
{
public:
long* key;
int capacity;
node** nodes;
node* parent;
long* value;
node ( int order ) {
key = new long[order + 1];
value = new long[order + 1];
nodes = new node *[order + 2];
capacity = 0;
parent = NULL;
for ( int i = 0; i <= order + 1; i++ ) {
this->nodes[i] = NULL;
}
}
~node() {
delete[] key;
delete[] value;
for ( int i = 0; i <= order + 1; i++ ) {
delete nodes[i];
}
}
};