内置数据类型:
#include
using namespace std;
#include
#include
//replace
//内置数据类型...)
{
cout << val << " ";
}
};
void test01()
{
vector v = { 4,7,2,7,8,7,9,7,10 };
cout << "替换前...:";
for_each(v.begin(), v.end(), p());
cout << "\n替换后: ";
replace(v.begin(), v.end(), 7, 520);
for_each...:\n";
for_each(v.begin(), v.end(), p());
//因为要查找与p1值相符的元素,所以涉及到了比较,如果是自定义数据类型,要重载==,返回值为bool
replace...(v.begin(), v.end(), p1, p4);
cout << "\n替换后: \n";
for_each(v.begin(), v.end(), p());
}
int main()