...  NODETYPE> class Tree {
11   public:
12      // insert node in Tree
13      void insertNode(const NODETYPE& value) {
14         insertNodeHelper(&rootPtr , value);
15      }
16
17      // begin preorder traversal of Tree
18      void preOrderTraversal() const {
19         preOrderHelper(rootPtr);
20      }
21
22      // begin inorder traversal of Tree
23      void inOrderTraversal() const {
24         inOrderHelper(rootPtr);
25      } 
26
27      // begin postorder traversal of Tree
28      void postOrderTraversal() const {
29         postOrderHelper(rootPtr);
30      }
31
32   private:
33      TreeNode<NODETYPE>* rootPtr{nullptr};
34
35      // utility function called by insertNode; receives a pointer
36      // to a pointer so that the function can modify pointer"s value
37      void insertNodeHelper(
38         TreeNode<NODETYPE>** ptr, const NODETYPE& value) {

Get C++ How to Program, 10/e now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.