Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BinaryTreeStorage::~BinaryTreeStorage(void)
- {
- try
- {
- // destroy(ROOT->left);
- //destroy(ROOT->right);
- destroy(ROOT);
- delete ROOT;
- }
- catch(int &e )
- {
- cerr << "Nothing to delete" << e << endl;
- }
- }
- // my method
- void BinaryTreeStorage::destroy(TreeNode *Child)
- {
- if(Child!=NULL)
- {
- destroy(Child->left);
- destroy(Child->right);
- delete Child;
- }
- else
- {
- delete Child;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment