C++ examples for STL:list
Storing strings in a list
#include <string> #include <list> #include <algorithm> #include <iostream> using namespace std; void write(const string& s) { cout << s << '\n'; } int main() {//from www.j a v a 2 s. com list<string> lst; string s = "a"; lst.push_front(s); s = "b"; lst.push_back(s); s = "c"; lst.push_back(s); for_each(lst.begin(), lst.end(), write); }