list1.cpp
来自「BigC++的源码」· C++ 代码 · 共 41 行
CPP
41 行
#include <string>
#include <list>
#include <iostream>
using namespace std;
int main()
{
list<string> staff;
staff.push_back("Cracker, Carl");
staff.push_back("Hacker, Harry");
staff.push_back("Lam, Larry");
staff.push_back("Sandman, Susan");
/* add a value in fourth place */
list<string>::iterator pos;
pos = staff.begin();
pos++;
pos++;
pos++;
staff.insert(pos, "Reindeer, Rudolf");
/* remove the value in second place */
pos = staff.begin();
pos++;
staff.erase(pos);
/* print all values */
for (pos = staff.begin(); pos != staff.end(); pos++)
cout << *pos << "\n";
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?