title: recursively delete every nodes in binary tree
body: <p>Following is my code to recursively delete every nodes in a Binary Search Tree:</p>
  
  <pre><code>template &lt;class T&gt;
  bool BST&lt;T&gt;::clear()
  {
      if(root == NULL)
      {
          cout &lt;&lt; "Empty" &lt;&lt; endl;
          return false;
      }
      else
      {
          clearNodes(root);
          return true;
      }
  
  }
  
  template &lt;class T&gt;
  void BST&lt;T&gt;::clearNodes(BTNode&lt;T&gt; *cur)
  {
      if(cur == NULL)
      {
          return;
      }
  
      clearNodes(cur-&gt;left);
      clearNodes(cur-&gt;right);
  
      delete cur;
  }
  </code></pre>
  
  <p>In my main function, when I try to print out the content to check whether the nodes are deleted after running my clear function, somehow I encounter the weird display here:
  <a href="https://i.stack.imgur.com/alihW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/alihW.png" alt="Image"></a></p>
  
  <p>May I know that is my nodes are actually deleted through the clear function above? </p>
  
  <p>Thanks for your guides!</p>