title: Recursive C++ function not returning correct boolean value
body: <p>This function is supposed to be returning true if the value is one of the first n entries of a vector and false if it isn't. I've been working on this for a while and can't figure out why it isn't working correctly.</p>
  
  <pre><code>template &lt;class T&gt;
  bool find(const vector&lt;T&gt; &amp;v,  T value, int n) {
      //base case
      if (n == 0) {
          cout &lt;&lt; "not here" &lt;&lt; endl;
          return false;
      }
      //general case
      if (v[n] == value) {
          cout &lt;&lt; v[n] &lt;&lt; " == " &lt;&lt; value &lt;&lt; endl;
          return true;
      }
      cout &lt;&lt; "find(" &lt;&lt; "v" &lt;&lt; ", " &lt;&lt; value &lt;&lt; ", " &lt;&lt; n - 1 &lt;&lt; ")" &lt;&lt; endl;
      find(v, value, n - 1);
  }
  </code></pre>
  
  <p>The couts are only there because I suck at debugging. Here's what I tested it with and the results:</p>
  
  <pre><code>vector&lt;int&gt; v = {1, 2, 3, 4, 5};
  cout &lt;&lt; boolalpha &lt;&lt; find(v, 3, 4);
  </code></pre>
  
  <p>Console:</p>
  
  <pre><code>find(v, 3, 3)
  find(v, 3, 2)
  3 == 3
  false
  </code></pre>
  
  <p>Clearly, the function is finding the matching value, but I'm extremely confused why it's still returning false anyway.</p>