#include <deque>
#include <iostream>
using namespace std;
typedef deque<char> CHARDEQUE;
void print_contents(CHARDEQUE deque, char*);
int main(void)
{
CHARDEQUE a(3, 'A');
CHARDEQUE 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");
a.assign(b.begin(),b.begin()+2);
print_contents(a, "a");
a.assign(3, 'Z');
print_contents(a, "a");
}
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;
}