共用方式為


operator!= (set)

測試,如果在運算子左方的集合物件不等於右邊的集合物件。

bool operator!=( 
   const set <Key, Traits, Allocator>& _Left, 
   const set <Key, Traits, Allocator>& _Right 
);

參數

  • _Left
    型別 set物件。

  • _Right
    型別 set物件。

傳回值

true ,如果集合不相等; false ,如果集合是否相等。

備註

集合中物件之間的比較可能會根據其元素之間的比較配對。 兩個集合相等,則它們具有相同項目數目,而其個別項目具有相同的值。 否則就是不相等。

範例

// set_op_ne.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   set <int> s1, s2, s3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      s1.insert ( i );
      s2.insert ( i * i );
      s3.insert ( i );
   }

   if ( s1 != s2 )
      cout << "The sets s1 and s2 are not equal." << endl;
   else
      cout << "The sets s1 and s2 are equal." << endl;

   if ( s1 != s3 )
      cout << "The sets s1 and s3 are not equal." << endl;
   else
      cout << "The sets s1 and s3 are equal." << endl;
}
  

需求

標頭: <set>

命名空間: std

請參閱

參考

標準樣板程式庫