C++ 提高教程 STL -容器算法迭代器初识

Posted 行码阁119

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C++ 提高教程 STL -容器算法迭代器初识相关的知识,希望对你有一定的参考价值。

 

 1 第一种遍历方式

	vector<int>::iterator itBegin = v.begin(); //起始迭代器,指向容器中的第一个元素
	vector<int>::iterator itEnd = v.end();//结束迭代器 指向容器中最后一个元素的下一个位置
	//第一种遍历方式:
	while (itBegin != itEnd)
	{
		
		cout << *itBegin << endl;
		itBegin++;
	}

 2 第二种遍历方式

	for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
	{
		cout << *it <&l

以上是关于C++ 提高教程 STL -容器算法迭代器初识的主要内容,如果未能解决你的问题,请参考以下文章

C++ 提高教程 STL-字符串对比

C++提高教程 STL -String查找和替换

C++提高教程 STL -string赋值操作

C++ 提高教程 STL-string字串

C++ 提高教程 STL -string字符串拼接

C++ 提高教程 STL -Vector存放自定义数据类型