共用方式為


operator!= (<stack>)

測試,如果在運算子左方的堆疊物件是堆疊右邊的物件的不相等。

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

參數

  • _Left
    型別 stack物件。

  • _Right
    型別 stack物件。

傳回值

true ,如果堆疊或堆疊不相等; false ,如果堆疊或堆疊是相等的。

備註

堆疊物件之間的比較可能會依據其項目比較配對。 兩個堆疊是相等的,如果它們有相同的元素數,且其元素具有相同的值。 否則就是不相等。

範例

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

int main( )
{
   using namespace std;

   // Declares stacks with vector base containers
   stack <int, vector<int> > s1, s2, s3;

   // The following would have cause an error because stacks with
   // different base containers are not equality comparable
   // stack <int, list<int> >  s3;

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

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

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

需求

標題: <堆疊>

命名空間: std

請參閱

參考

標準樣板程式庫