C++ advance()运用案例
#include <iterator> #include <iostream> #include <list> #include <algorithm> using namespace std; int main() { list<int> list1; for (int i=0;i<10;++i) { list1.push_back(i); } list<int>::iterator pos1 = list1.begin(); cout << "" << *pos1 << endl; // advance(pos1, 3); // cout<<""<<*pos1<<endl; // advance(pos1, -1); cout << "" << *pos1 << endl; system("pause"); return 0; }
0
3
2
请按任意键继续. . .
代码参考:C++标准库(第2版)