vector的重载了==(虽然帮助文档里没看到),其判定也是严格按照顺序每一个元素相同的方法。
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main()
{
vector<int> a, b,c,d;
a.push_back(1);
a.push_back(2);
b.push_back(1);
b.push_back(2);
c.push_back(2);
c.push_back(1);
d.push_back(1);
d.push_back(2);
d.push_back(3);
if (a == b)
cout << "a==b" << endl;
else
{
cout << "a!=b" << endl;
}
if (a == c)
cout << "a==c" << endl;
else
{
cout << "a!=c" << endl;
}
if (a == d)
cout << "a==d" << endl;
else
{
cout << "a!=d" << endl;
}
return 0;
}