bool swap(deque<X, A>& qrD1, deque<X, A>& qrD2);
#include <deque>
#include <iostream>
#include <deque>
int main()
{
using namespace std;
// Create a two deque instances and add bits to them
deque<bool> qD1;
qD1.push_back(true);
qD1.push_back(false);
qD1.push_back(false);
qD1.push_back(true);
deque<bool> qD2;
qD2.push_back(false);
qD2.push_back(true);
// Output the deques and the swapped versions
for (int i = 0; i < 2; ++i) {
cout << "D1 = ";
deque<bool>::iterator qIter;
for (qIter = qD1.begin(); qIter != qD1.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
cout << "D2 = ";
for (qIter = qD2.begin(); qIter != qD2.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
if (i == 0) {
cout << "swap deques" << endl;
}
swap(qD1, qD2);
}
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.