#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
template<typename T, typename _func>
_func formyeach(T b, T e, _func func){
for(;b!=e;++b)
{
func(*b);
}
return func;
}
void print(int elem){
cout<<elem<<endl;
}
typedef void(* second_print)(int);
int main()
{
vector<int> v(30,9);
for_each(v.begin(),v.end(),&print);
cout<<"------------------------------"<<endl;
formyeach(v.begin(),v.end(),&print);
second_print fun= &print;
fun(3);
return 0;
}