All pastes #243261 Raw Edit

Mine

public text v1 · immutable
·published 2006-11-08 07:26 UTC
rendered paste body
#include <string>
#include <list>
#include <algorithm>
#include <iostream>

using namespace std;

void write( const string& s ) 
{
        cout << s << endl;
}

int main( int argc, char* argv[] )
{
        list<string> lst;

        string s = "knife";
        lst.push_front( s );

        s = "fork";
        lst.push_back( s );

        s = "spoon";
        lst.push_back( s );

        // A list doesn't have random access, so 
        // use for_each() instead
        for_each( lst.begin(), lst.end(), write );

        return 0;
}