⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listsplice.cpp

📁 C++高级编程这本书所附的源代码
💻 CPP
字号:
#include <list>#include <string>#include <iostream>using namespace std;int main(int argc, char** argv){  list<string> dictionary, bWords;  // Add the a words  dictionary.push_back("aardvark");  dictionary.push_back("ambulance");  dictionary.push_back("archive");  // Add the c words  dictionary.push_back("canticle");  dictionary.push_back("consumerism");  dictionary.push_back("czar");  // create another list of the b words  bWords.push_back("bathos");  bWords.push_back("balderdash");  bWords.push_back("brazen");  // splice the b words into the main dictionary.  list<string>::iterator it;  int i;  // Iterate up to the spot where we want to insert bs  // for loop body intentionally empty -- we're just moving up three elements  for (it = dictionary.begin(), i = 0; i < 3; ++it, ++i);  // Add in the bwords. This action removes the elements from bWords.  dictionary.splice(it, bWords);  // print out the dictionary  for (it = dictionary.begin(); it != dictionary.end(); ++it) {    cout << *it << endl;  }  return (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -