共用方式為


operator<= (<stack>)

測試,如果在運算子左方的堆疊物件小於或等於右邊的堆疊物件。

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

參數

  • _Left
    型別 stack物件。

  • _Right
    型別 stack物件。

傳回值

true ,如果在運算子左方的堆疊小於或等於堆疊在運算子右方的;否則 false

備註

堆疊物件之間的比較可能會依據其項目比較配對。 小於或等於兩個堆疊物件之間的關聯性會根據第一個要比較不相等的項目。

範例

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

int main( )
{
   using namespace std;

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

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

   if ( s1 <= s2 )
      cout << "The stack s1 is less than or equal to "
           << "the stack s2." << endl;
   else
      cout << "The stack s1 is greater than "
           << "the stack s2." << endl;

   if ( s1 <= s3 )
      cout << "The stack s1 is less than or equal to "
           << "the stack s3." << endl;
   else
      cout << "The stack s1 is greater than "
           << "the stack s3." << endl;
}
  

需求

標題: <堆疊>

命名空間: std

請參閱

參考

標準樣板程式庫