I insert struct to vector,but address of all the elements of vector are same : <p>I declared a struct treenode</p>

<pre><code>struct treenode {
    int val;
    treenode *l;
    treenode *r;
};
</code></pre>

<p>and a vector</p>

<pre><code>vector&lt;int&gt; v = { 1,2,3,4,5,6,7,8,9 };
</code></pre>

<p>now I want to create a vector tv to store the value of v</p>

<pre><code>vector&lt;treenode* &gt; tv;
for (int i = 0; i &lt; v.size(); i++)
    {
        treenode mid;
        mid.val = v[i];
        mid.l = NULL;
        mid.r = NULL;
        tv.push_back(&amp;mid);
    }
</code></pre>

<p>but when I print the value of tv, I found all the element of tv are same(same address), there are 9. I`m confused, I　have create a new treenode every iteration, why all the element use same address
<a href="http://i.stack.imgur.com/DmrC7.png" rel="nofollow">enter image description here</a></p>
