次の方法で共有


operator> (<stack>)

演算子の左側のスタックのオブジェクトが右側のオブジェクトより大きいスタックのテスト。

bool operator>(
   const stack <Type, Container>& _Left,
   const stack <Type, Container>& _Right
);

パラメーター

  • _Left
    **[スタック]**型のオブジェクト。

  • _Right
    **[スタック]**型のオブジェクト。

戻り値

演算子の左側のスタックが大きくなり、等しくない場合に、演算子の右側のスタックtrue ; それ false

解説

スタックのオブジェクトの比較は、要素のペアに比較に基づいています。2 個のスタックのオブジェクト間の関係に不等号最初のペアの付いていない要素の比較に基づいています。

使用例

// stack_op_gt.cpp
// compile with: /EHsc
#include <stack>
#include <list>
#include <iostream>

int main( )
{
   using namespace std;

   // Declares stacks with list base container
   stack <int, list<int> > s1, s2, s3;

   s1.push( 1 );
   s1.push( 2 );
   s1.push( 3 );
   s2.push( 5 );
   s2.push( 10 );
   s3.push( 1 );
   s3.push( 2 );

   if ( s1 > s2 )
      cout << "The stack s1 is greater than "
           << "the stack s2." << endl;
   else
      cout << "The stack s1 is not greater than "
           << "the stack s2." << endl;

   if ( s1> s3 )
      cout << "The stack s1 is greater than "
           << "the stack s3." << endl;
   else
      cout << "The stack s1 is not greater than "
           << "the stack s3." << endl;
}
  
  

必要条件

ヘッダー: <stack>

名前空間: std

参照

関連項目

標準テンプレート ライブラリ