首页 > 其他 > 详细

for_each函数

时间:2015-05-19 19:03:54      阅读:172      评论:0      收藏:0      [点我收藏+]

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;
	}


for_each函数

原文:http://blog.csdn.net/xiao_lxl/article/details/45847443

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!