template <class X, class A> bool swap(vector<X, A>& qrV1, vector<X, A>& qrV2);
#include <vector>
#include <iostream> #include <vector> int main() { using namespace std; // Create a two vector instances and add bits to them vector<bool> qV1; qV1.push_back(true); qV1.push_back(false); qV1.push_back(false); qV1.push_back(true); vector<bool> qV2; qV2.push_back(false); qV2.push_back(true); // Output the vectors and the swapped version for (int i = 0; i < 2; ++i) { cout << "V1 = "; vector<bool>::iterator qIter; for (qIter = qV1.begin(); qIter != qV1.end(); ++qIter) { cout << *qIter; } cout << endl; cout << "V2 = "; for (qIter = qV2.begin(); qIter != qV2.end(); ++qIter) { cout << *qIter; } cout << endl; if (i == 0) { cout << "swap vectors" << endl; } swap(qV1, qV2); } cin.get(); return 0; }
© 20072025 XoaX.net LLC. All rights reserved.