operator> (<stack>)
测试,如果运算符左侧的对象堆大于右侧的大对象堆。
bool operator>(
const stack <Type, Container>& _Left,
const stack <Type, Container>& _Right
);
参数
_Left
类型 stack对象。_Right
类型 stack对象。
返回值
true,如果运算符左侧的堆栈与和并不等于于堆栈是大于在运算符的右侧;为 false。
备注
在堆栈对象之间的比较基于元素的一种比较成对。 大于两个堆栈对象之间的关系。根据第一个不相等对比较元素。
示例
// 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;
}
要求
页眉: <堆栈>
命名空间: std