operator<= (<vector>)
测试,如果运算符左侧的对象小于或等于右侧的对象。
bool operator<=(
const vector<Type, Allocator>& _Left,
const vector<Type, Allocator>& _Right
);
参数
_Left
类型 vector对象。_Right
类型 vector对象。
返回值
true,如果运算符左侧的向量或等于 right 矢量在运算符的右侧;为 false。
示例
// vector_op_le.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
vector <int> v1, v2;
v1.push_back( 1 );
v1.push_back( 2 );
v1.push_back( 4 );
v2.push_back( 1 );
v2.push_back( 3 );
if ( v1 <= v2 )
cout << "Vector v1 is less than or equal to vector v2." << endl;
else
cout << "Vector v1 is greater than vector v2." << endl;
}
要求
标头: <vector>
命名空间: std