void DeleteChildren(BSTNode *node)
{
// Recurse left down the tree...
if(node->HasLeftChild()) DeleteChildren(node->GetLeftChild());
// Recurse right down the tree...
if(node->HasRightChild()) DeleteChildren(node->GetRightChild());
// Clean up the data at this node.
node->ClearData(); // assume deletes internal data
// Free memory used by the node itself.
delete node;
}
// Call this from external code.
DeleteChildren(rootNode);
이 기능은 BST를 재귀 적으로 삭제하는 기능입니다.함수 매개 변수 - 포인터 또는 포인터에 대한 참조?
첫 번째 줄에 대해 BSTNode *node
, 으로 수정해야합니까? BSTNode *& node
으로 수정해야합니까?
뭔가 잘못되었다고 생각하는 코드에 문제가 있습니까? 그것은 나에게 잘 보인다. – Kai