I need help in deleting all the leaf nodes in BST
void BinarySearchTree::removeLeaves()
{
removeleaf(root);
}
void BinarySearchTree::removeleaf(tree_node* p)
{
if(p != NULL)
{
if(p->left) removeleaf(p->left);
if(p->right) removeleaf(p->right);
delete p;
}
else return;
}
can someone check my code.
pls