STL容器遍历6种方法
1、使用下标进行遍历(要求容器必须自持下标访问的,list不支持下标,所以不适用)
1 for(size_t idx =0;idx != numbers.szie(); ++idx)
2 {
3 cout << numbers[idx] << " ";
4 }
5 cout << endl;
1、使用下标进行遍历(要求容器必须自持下标访问的,list不支持下标,所以不适用)
1 for(size_t idx =0;idx != numbers.szie(); ++idx)
2 {
3 cout << numbers[idx] << " ";
4 }
5 cout << endl;