This topic has not yet been rated - Rate this topic

operator>= (<stack>)

Tests if the stack object on the left side of the operator is greater than or equal to the stack object on the right side.

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

An object of type stack.

_Right

An object of type stack.

true if the stack on the left side of the operator is strictly less than the stack on the right side of the operator; otherwise false.

The comparison between stack objects is based on a pairwise comparison of their elements. The greater than or equal to relationship between two stack objects is based on a comparison of the first pair of unequal elements.

// stack_op_ge.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 );
   s2.push( 5 );
   s2.push( 10 );
   s3.push( 1 );
   s3.push( 2 );

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

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

Header: <stack>

Namespace: std

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.