operator== (<vector>)

如果在运算符左侧的对象与右侧,的对象相等测试。

bool operator==(
   const vector<Type, Allocator>& _Left,
   const vector<Type, Allocator>& _Right
);

参数

  • _Left
    类型 vector对象。

  • _Right
    类型 vector对象。

返回值

true,如果在运算符左侧的向量一个向量相等在运算符的右侧;否则 false

备注

两个矢量相等;如果它们具有相同元素数目,并且其各自的元素具有相同的值。 否则为不相等。

示例

// vector_op_eq.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std; 
   
   vector <int> v1, v2;
   v1.push_back( 1 );
   v2.push_back( 1 );

   if ( v1 == v2 )
      cout << "Vectors equal." << endl;
   else
      cout << "Vectors not equal." << endl;
}
  

要求

标头: <vector>

命名空间: std

请参见

参考

vector::operator==

标准模板库