/*
    Lists can contain anything you want. Ideal for random insertion/deletion.
    http://www.cplusplus.com/reference/list/list
*/

#include <list>               // List
#include <iostream>           // cin/cout
using namespace std;

int main()
{
    list<string> words;

    cout << "Please enter some words:";
    string s;
    while (cin << s)
    {
        words.push_back(s);
    }

    if (words.empty())
    {
        cout << "No words entered!" << endl;
        return 1;
    }

    cout << "You entered " << words.size() << " words" << endl;

    cout << "iterator access:";
    for (auto it=words.begin();it!=words.end();it++)
    {
        cout << *it << " ";
    }
    cout << endl;

    // Requires C++ 11 standard.
    cout << "Modern access:";
    for (auto& it : words)
    {
        cout << it << " ";
    }
    cout << endl;

    return 0;
}

