测试,如果运算符左侧的对象对与对不等于右侧的对象。
template<Class Type>
bool operator!=(
const Type& _Left,
const Type& _Right
);
template<class Type1, class Type2>
bool operator!=(
const pair<Type1, Type2>& _Left,
const pair<Type1, Type2>& _Right
);
参数
_Left
**pair.**类型对象_Right
pair 类型的对象。
返回值
true,如果对不相等;false,如果对不相等。
备注
如果为每单个元素相等,一对与另一对值相等。 如果第一或第二个元素一个与其他对的对应元素,而不是相等的两对不相等的。
示例
// utility_op_ne.cpp
// compile with: /EHsc
#include <utility>
#include <iomanip>
#include <iostream>
int main( )
{
using namespace std;
pair <int, double> p1, p2, p3;
p1 = make_pair ( 10, 1.11e-1 );
p2 = make_pair ( 1000, 1.11e-3 );
p3 = make_pair ( 10, 1.11e-1 );
cout.precision ( 3 );
cout << "The pair p1 is: ( " << p1.first << ", "
<< p1.second << " )." << endl;
cout << "The pair p2 is: ( " << p2.first << ", "
<< p2.second << " )." << endl;
cout << "The pair p3 is: ( " << p3.first << ", "
<< p3.second << " )." << endl << endl;
if ( p1 != p2 )
cout << "The pairs p1 and p2 are not equal." << endl;
else
cout << "The pairs p1 and p2 are equal." << endl;
if ( p1 != p3 )
cout << "The pairs p1 and p3 are not equal." << endl;
else
cout << "The pairs p1 and p3 are equal." << endl;
}
要求
页眉: <实用工具>
命名空间: std