共用方式為


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 ,如果在運算子左方的 pair 大於或等於 pair 在運算子的右邊;否則 false

備註

在要比較,兩組值的第一個項目具有最高優先權。 如果兩者不同,因為要比較,則其比較的結果進行。 如果第一個項目的值不同,則第二個項目的值會比較中型別為的比較,因此,其比較的結果進行。

範例

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

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

   p1 = make_pair ( 10, 2.22e-1 );
   p2 = make_pair ( 100, 1.11e-1 );
   p3 = make_pair ( 10, 1.11e-1 );
   p4 = make_pair ( 10, 2.22e-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;
   cout << "The pair p4 is: ( " << p4.first << ", " 
        << p4.second << " )." << endl << endl;

   if ( p1 >= p2 )
      cout << "Pair p1 is greater than or equal to pair p2." << endl;
   else
      cout << "The pair p1 is less than the pair p2." << endl;

   if ( p1 >= p3 )
      cout << "Pair p1 is greater than or equal to pair p3." << endl;
   else
      cout << "The pair p1 is less than the pair p3." << endl;

   if ( p1 >= p4 )
      cout << "Pair p1 is greater than or equal to pair p4." << endl;
   else
      cout << "The pair p1 is less than the pair p4." << endl;
}
  

需求

標題: <公用程式>

命名空間: std