#pragma hdrstop
#pragma argsused

#include <tchar.h>
#include <stdio.h>

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

// for_each example.
// from: http://www.cplusplus.com/reference/algorithm/for_each/

void myfunction (int i) {
  cout << " " << i;
}

struct myclass {
  void operator() (int i) {cout << " " << i;}
} myobject;

int _tmain(int argc, _TCHAR* argv[])
{
	vector<int> myvector;
	myvector.push_back(10);
	myvector.push_back(20);
	myvector.push_back(30);

	cout << "myvector contains:";
	for_each (myvector.begin(), myvector.end(), myfunction);

	// or:
	cout << "\nmyvector contains:";
	for_each (myvector.begin(), myvector.end(), myobject);

	cout << endl;
	cin.get();
	return 0;
}
