c++ vectors and pointers
<p>As i understand if i dont store pointers, everything in c++ gets copied, which can lead to bad performance (ignore the simplicity of my example). So i thought i store my objects as pointers instead of string object inside my vector, thats better for performance right? (assumining i have very long strings and lots of them).</p>

<p>The problem when i try to iterate over my vector of string pointers is i cant extract the actual value from them</p>

<pre><code>string test = "my-name";
vector&lt;string*&gt; names(20);
names.push_back(&amp;test);

vector&lt;string*&gt;::iterator iterator = names.begin();
while (iterator != names.end())
{
    std::cout &lt;&lt; (*iterator) &lt;&lt; ":" &lt;&lt; std::endl;
    // std::cout &lt;&lt; *(*iterator); // fails

    iterator++;
}
</code></pre>

<p>See the commented line, i have no problem in receiving the string pointer. But when i try to get the string pointers value i get an error (i couldnt find what excatly the error is but the program just fails).</p>

<p>I also tried storing (<em>iterator) in a new string</em> variable and but it didnt help?</p>
