#include <iostream>
#include <deque>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
deque<char> dequeObject1(30), dequeObject2, dequeObject3;
int i;
char str1[] = "forward";
for(i = 0; str1[i]; i++)
dequeObject2.push_back(str1[i]);
copy(dequeObject2.begin(), dequeObject2.end(), dequeObject1.begin());
cout << "Contents dequeObject1 after forward copy:\n";
for(i = 0; i <dequeObject1.size(); i++)
cout << dequeObject1[i];
cout << "\n\n";
char str2[] = "backward";
for(i = 0; str2[i]; i++)
dequeObject3.push_back(str2[i]);
copy(dequeObject3.rbegin(), dequeObject3.rend(), dequeObject1.begin()+strlen(str1));
cout << "Contents dequeObject1 after reverse copy:\n";
for(i = 0; i <dequeObject1.size(); i++)
cout << dequeObject1[i];
return 0;
}
|