First page Back Continue Last page Graphics
int main( )
- int main( )
- { list<int> coll;
- for(int i=1; i<=9; ++i) coll.push_back(i);
- PRINT_ELEMENTS(coll,”initialized: “);
- // add value 10 to each element
- for_each(coll.begin( ), coll.end( ), AddValue(10));
- PRINT_ELEMENTS(coll,”after adding 10: “);
- // add the value of the first element to each element
- for_each(coll.begin( ), coll.end( ),
- AddValue(*coll.begin( ) ) );
- PRINT_ELEMENTS(coll, “after adding the first element: “);
- }