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

请参见

参考

标准模板库