[root@localhost testc++]# vi back_inserter.cpp
1 #include <iostream>
2 #include <vector>
3 #include <algorithm>
4 #include <iterator>
5 using namespace std;
6
7 int main()
8 {
9 vector<int> vec;
10 fill_n(back_inserter(vec),10,0);
11 for(vector<int>::size_type i=0; i != vec.size();++i)
12 cout << vec[i] << endl;
13 return 0;
14 }
15
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"back_inserter.cpp" 15L, 277C written
[root@localhost testc++]# g++ back_inserter.cpp
[root@localhost testc++]# ./a.out
0
0
0
0
0
0
0
0
0
0
[root@localhost testc++]#
back_inserter 11.2.2- 3 插入迭代器
最新推荐文章于 2021-11-07 15:42:22 发布