/*Orion Lawlor's Simple STL Examples, olawlor@acm.org
Shows how to use std::for_each (with a function object).
*/
#include <iostream>
#include <algorithm>

class writeOut { public:
	void operator() (const char *str) {
		std::cout<<str<<std::endl;
	}
};

int main()
{
	const char *start[]={"foo","bar","baz"};
	const int len=sizeof(start)/sizeof(start[0]);
	const char **end=&start[len];
	writeOut w;
	
	std::for_each(start,end,w); //calls w("foo"); w("bar"); ...
	return 0;
}
/*<@>
<@> ******** Program output: ********
<@> foo
<@> bar
<@> baz
<@> */
