当前位置:首页>开发>正文

怎样遍历list?

2023-04-22 19:59:02 互联网 未知 开发

 怎样遍历list?

怎样遍历list?

C 模板类list都是用迭代器iterator来遍历链表

#include <list>
#include <iostream>

using std::list
using std::cout
using std::endl

void main(void)
{
int a[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
list<int> name(a,a 10)

std::list<int>::iterator it
for (it = name.begin() it != name.end() it )
{
cout << *it << endl
}
}

最新文章