for_each函数的用法
std::for_each(cpths.begin(), cpths.end(), print);
其中print函数为
void print(const std::string& e)
{
std::cout << e << std::endl;
}
以上语句 等价于:
std::vector<std::string>::const_iterator iter = cpths.begin();
for (; iter != cpths.end(); ++iter)
{
cout<<*iter<<endl;
}