title: How to traverse a binary tree and count the occurrence of a value without passing in a value
body: <p>I am currently working on a program to implement a binary search tree. The struct for the tree is as follows:</p>
  
  <pre><code>struct treeNode {
      Type value;
      int count;
      treeNode* left;
      treeNode* right;
  };
  treeNode* root;
  </code></pre>
  
  <p>I am trying to implement the following function:</p>
  
  <pre><code>template &lt;class Type&gt;
  int bstree&lt;Type&gt;::count(){
  
  return count(root);
  }
  
  template &lt;class Type&gt;
  int bstree&lt;Type&gt;::count(treeNode* sroot){
  
  
  }
  </code></pre>
  
  <p>I am trying to figure out how I would visit every node and add up all the count values for each node.</p>