首先,欢迎并感谢博友进行知识补充与修正。
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//迭代器三种遍历方式
void Myprint(int e) //回调函数
{
cout << e << endl;
}
void test01()
{
vector<int> v = { 1, 2, 3, 4, 5 };
vector<int>::iterator itBegin = v.begin();
vector<int>::iterator itEnd = v.end();
while (itBegin != itEnd)
{
cout << *(itBegin++) << endl;
}
}
void test02()
{
vector<int> v = { 1, 2, 3, 4, 5 };
for (vector<int>::iterator it=v.begin();it!=v.end();it++)
{
cout << *it << endl;
}
}
void test03()
{
vector<int> v = { 1, 2, 3, 4, 5 };
for_each(v.begin(), v.end(), Myprint);
}
class Person
{
public:
Person(string name, int age)
{
this->m_name = name;
this->m_age = a