?? chapter7-16.cpp
字號:
//文件名:CHAPTER7-16.cpp
#include <iostream>
#include <deque>
#if _MSC_VER > 1020 // if VC++ version is > 4.2
using namespace std; // std c++ libs implemented in std
#endif
typedef deque<char > CHARDEQUE;
void print_contents (CHARDEQUE deque, char*);
int main()
{
CHARDEQUE a(3,'A'); //定義了變量a,內(nèi)容是3個'A'
CHARDEQUE b(4,'B'); //定義了變量b,內(nèi)容是4個'B'
print_contents (a,"a");
print_contents (b,"b");
a.swap(b); //內(nèi)容互換
print_contents (a,"a");
print_contents (b,"b");
a.swap(b);//內(nèi)容換回來
print_contents (a,"a");
print_contents (b,"b");
a.assign(b.begin(),b.end());
print_contents (a,"a");
a.assign(b.begin(),b.begin()+2);
print_contents (a,"a");
a.assign(3,'Z');
print_contents (a,"a");
return 0;
}
//下面是顯示函數(shù)源代碼
void print_contents (CHARDEQUE deque, char *name)
{
CHARDEQUE::iterator pdeque;
cout <<"The contents of "<< name <<" : ";
for(pdeque = deque.begin();
pdeque != deque.end();
pdeque++)
{
cout << *pdeque <<" " ;
}
cout<<endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -