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

📄 chapter8-23.cpp

📁 C++STL程序员开发指南
💻 CPP
字号:
//文件名:CHAPTER8-23.cpp
#include <iostream>
#include <list>
#if _MSC_VER > 1020   // if VC++ version is > 4.2
   using namespace std;  // std c++ libs implemented in std
#endif
typedef list<char >  CHARLIST;
void print_contents (CHARLIST  list, char*);
int main()
{
    CHARLIST  a(3,'A'); //定义了变量a,内容是3个'A'
    CHARLIST  b(4,'B'); //定义了变量b,内容是4个'B'
    print_contents (a,"a");
    print_contents (b,"b");
    a.swap(b); //内容互换
    print_contents (a,"a");
    print_contents (b,"b");
    a.swap(b);//内容换回来
    print_contents (a,"a");
    print_contents (b,"b");
    a.assign(b.begin(),b.end());
    print_contents (a,"a");
	   CHARLIST::iterator itor=b.begin();
	   itor++;
itor++;
    a.assign(b.begin(),itor);
    print_contents (a,"a");
    a.assign(3,'Z');
    print_contents (a,"a");
	   return 0;
}
//下面是显示函数源代码
void print_contents (CHARLIST  list, char *name)
{
    CHARLIST::iterator plist;
    cout <<"The contents of "<< name <<" : ";
    for(plist = list.begin(); plist != list.end(); plist++)
    { cout << *plist <<" " ; }
    cout<<endl;
}

⌨️ 快捷键说明

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