#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
class person {
public:
int age;
string name;
person(string name, int age) {
this->name = name;
this->age = age;
}
};
void work(person* p)
{
cout << (*p).name << " " ;
cout << ( *p).age<< " " ;
}
int main() {
person a("王一", 18), b("王二", 19), c("王三", 20);
vector<person*> v;
v.push_back(&a);
v.push_back(&b);
v.push_back(&c);
vector<person*>::iterator begin = v.begin();
vector<person*>::iterator end = v.end();
for (; begin != end; begin++) {
cout << (*begin)->name << " " ;
cout << (*begin)->age<< " " ;
}
cout<<endl<<"__________________________________" << endl<<endl;
begin=v.begin();
for_each(begin,end,work);
return 0;
}