#include <iostream>
#include <list>
#include <string>
using namespace std;
// Simple example uses type int
main()
{
list<string > L;
L.push_back("test"); // Insert a new element at the end
L.push_back("testinggggg");
L.push_back("example");
list<string>::iterator i;
for(i=L.begin(); i != L.end(); ++i) {
string test = *i;
cout << test;
}
return 0;
}
I am not getting any output if I use the above program and if I change the string test=*i to cout << *i << " "; it works. What is the problem with this?