共用方式為


operator!= (<utility>)

測試,如果左側的物件與不等於右邊的物件。

template<Class Type>
   bool operator!=(
      const Type& _Left,
      const Type& _Right
   );
template<class Type1, class Type2>
   bool operator!=(
      const pair<Type1, Type2>& _Left,
      const pair<Type1, Type2>& _Right
   );

參數

  • _Left
    型別 **pair.**物件

  • _Right
    型別 pair 的物件。

傳回值

true ,如果物件不相等則為, false ,如果為相等。

備註

如果其每一個別項目相等,則為與另一個為相等。如果第一個或第二個項目一個與其他物件的對應項目,不相等的兩個物件不相等。

範例

// utility_op_ne.cpp
// compile with: /EHsc
#include <utility>
#include <iomanip>
#include <iostream>

int main( )
{
   using namespace std;
   pair <int, double> p1, p2, p3;

   p1 = make_pair ( 10, 1.11e-1 );
   p2 = make_pair ( 1000, 1.11e-3 );
   p3 = make_pair ( 10, 1.11e-1 );

   cout.precision ( 3 );
   cout << "The pair p1 is: ( " << p1.first << ", " 
        << p1.second << " )." << endl;
   cout << "The pair p2 is: ( " << p2.first << ", " 
        << p2.second << " )." << endl;
   cout << "The pair p3 is: ( " << p3.first << ", " 
        << p3.second << " )." << endl << endl;

   if ( p1 != p2 )
      cout << "The pairs p1 and p2 are not equal." << endl;
   else
      cout << "The pairs p1 and p2 are equal." << endl;

   if ( p1 != p3 )
      cout << "The pairs p1 and p3 are not equal." << endl;
   else
      cout << "The pairs p1 and p3 are equal." << endl;
}
  
  
  
  
  

需求

標題: <utility>

命名空間: std