list iterator problem in c++?
<pre><code>#include &lt;iostream&gt;
#include &lt;list&gt;
#include &lt;string&gt;
using namespace std;

// Simple example uses type int

main()
{
   list&lt;string &gt; L;
   L.push_back("test");              // Insert a new element at the end

 L.push_back("testinggggg"); 
 L.push_back("example"); 
   list&lt;string&gt;::iterator i;

   for(i=L.begin(); i != L.end(); ++i) {
       string test = *i;
       cout &lt;&lt; test;
   }
   return 0;
}
</code></pre>

<p>I am not getting any output if I use the above program and if I change the <code>string test=*i</code> to <code>cout &lt;&lt; *i &lt;&lt; " ";</code> it works. What is the problem with this?</p>
