Guest User

Untitled

a guest
May 7th, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. BinaryTreeStorage::~BinaryTreeStorage(void)
  2. {
  3.     try
  4.     {
  5. //  destroy(ROOT->left);
  6.     //destroy(ROOT->right);
  7.         destroy(ROOT);
  8.     delete ROOT;
  9.     }
  10.     catch(int  &e )
  11.     {
  12.         cerr << "Nothing to delete" << e << endl;
  13.     }
  14. }
  15.  
  16. // my method
  17. void BinaryTreeStorage::destroy(TreeNode *Child)
  18. {
  19.   if(Child!=NULL)
  20.   {
  21.     destroy(Child->left);
  22.     destroy(Child->right);
  23.     delete Child;
  24.   }
  25.   else
  26.   {
  27.       delete Child;
  28.   }
  29.  
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment