template <class X, class A> bool operator==(vector<X, A>, vector<X, A>);
#include <vector>
#include <iostream> #include <vector> int main() { using namespace std; vector<int>* qpaV[3]; // Create a three vector instances vector<int> qV1; qV1.push_back(4); qV1.push_back(5); qV1.push_back(1); qpaV[0] = &qV1; vector<int> qV2; qV2.push_back(1); qV2.push_back(5); qV2.push_back(4); qpaV[1] = &qV2; vector<int> qV3; qV3.push_back(1); qV3.push_back(5); qV3.push_back(4); qpaV[2] = &qV3; // Compare the vectors to each other and themselves for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { vector<int>::iterator qIter; for (qIter = qpaV[i]->begin(); qIter != qpaV[i]->end(); ++qIter) { cout << *qIter << " "; } // Apply the equal to operator to the ith and jth vectors cout << ((*(qpaV[i]) == *(qpaV[j])) ? "== " : "!= "); for (qIter = qpaV[j]->begin(); qIter != qpaV[j]->end(); ++qIter) { cout << *qIter << " "; } cout << endl; } } cin.get(); return 0; }
© 20072025 XoaX.net LLC. All rights reserved.