title: Correct way to use function pointers for traversal bst
body: <p>i am creating a binary search tree template class, and want to use function pointers for the inorder traversal function, i am okay with function pointers but for some reason am lost on how to use the inorder once the code is in place. not much other stuff online has helped me so any feed back would be great.</p>
  
  <pre><code>class Bst
  {
      struct Node
      {
          T data;
          Node * left;
          Node * right;
          Node(T key) :data(key), left(nullptr), right(nullptr) {}
      };
  
      typedef void(*inorderPtr)(T &amp;);
      typedef void(*preorderPtr)(T &amp;);
      typedef void(*postorderPtr)(T &amp;);
  
      Node * root;
      T &amp; GetItem() const;
      void deleteNode(Node*);
      void printNode(Node*);
      void inorder(Node * root, void (*inorderPtr)(T &amp;)) const;
      void preorder(Node * root) const;
      void postorder(Node * root) const;
  
  public:
  
      Bst();
      ~Bst();
      Bst(const Bst&lt;T&gt; &amp; source);
      const Bst&lt;T&gt; &amp; operator = (const Node &amp;);
      void insert(const T);
      void print();
      void inorder(void(*inorderPtr)(T &amp;)) const;
      void printPreorder() const;
      void printPostorder() const;
  };
  </code></pre>
  
  <p>some code is as follows for basic bst</p>
  
  <pre><code>template&lt;class T&gt;
  inline T &amp; Bst&lt;T&gt;::GetItem() const
  {
      return data;
  }
  
  template&lt;class T&gt;
  inline void Bst&lt;T&gt;::inorder(Node * root, void(*inorderPtr)(T &amp;)) const
  {
      if (root-&gt;left != nullptr)
      {
          inorder(root-&gt;left, inorderPtr);
      }
  
      inorderPtr(root-&gt;GetItem());
  
      if (root-&gt;right != nullptr)
      {
          inorder(root-&gt;right, inorderPtr);
      }
  }
  
  template&lt;class T&gt;
  inline void Bst&lt;T&gt;::inorder(void(*inorderPtr)(T &amp;)) const
  {   
      inorder(this-&gt;root, inorderPtr);
  }
  </code></pre>
  
  <pre><code>int main()
  {
          Bst&lt;int&gt; tree;
  
      for (int i = 0; i &lt; 100; i++)
      {
          tree.insert(i);
      }
  
      tree.inorder();
  
  }
  </code></pre>
  
  <p>the main is basic test but having trouble with inorder(); not enough arguments</p>