title: Having trouble with creating a tree from a vector
body: <p>I am trying to turn an int vector into a binary search tree. I am using Cygwin on Windows if that matters. For some reason, after tracing I found that "next" has the same address every iteration of the loop. Could someone tell me where I am going wrong?</p>
  
  <p>edit: replaced my empty check line with "if (numbers.empty()) return;"</p>
  
  <pre class="lang-cpp prettyprint-override"><code>Tree::Tree(std::vector&lt;int&gt; numbers){
          if (numbers.empty()) return;
          node *current = &amp;root;
          current-&gt;num = *numbers.begin();
          node *next;
          for (std::vector&lt;int&gt;::iterator it = numbers.begin() + 1; it != numbers.end(); it++){
                  next = new node();
                  next-&gt;num = *it;
                  if (*it &gt;= current-&gt;num){
                          current-&gt;right = next;
                          current = current-&gt;right;
                  } else {
                          current-&gt;left = next;
                          current = current-&gt;left;
                  }
          }
  }
  </code></pre>