operator!= (<utility>)
如果在运算符的左边对对象与右侧,对对象不相等测试。
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;
}
标头: <utility>
命名空间: std