operator!= (<string>)
測試,如果左側的字串物件等於右邊的字串物件不相等。
template<class CharType, class Traits, class Allocator>
bool operator!=(
const basic_string<CharType, Traits, Allocator>& _Left,
const basic_string<CharType, Traits, Allocator>& _Right
);
template<class CharType, class Traits, class Allocator>
bool operator!=(
const basic_string<CharType, Traits, Allocator>& _Left,
const CharType *_Right
);
template<class CharType, class Traits, class Allocator>
bool operator!=(
const CharType *_Left,
const basic_string<CharType, Traits, Allocator>& _Right
);
參數
_Left
C. 式字串或型別要比較的 basic_string 物件。_Right
C. 式字串或型別要比較的 basic_string 物件。
傳回值
true ,如果左側的字串物件等於右邊的字串物件不是 Dictionary 地相等,否則 false。
備註
在字串物件之間的比較可能會根據其字元配對方式字典比較。 兩個字串相等則為,如果它們有相同數目的字元,而且其個別字元值與相同。 否則就是不相等。
範例
// string_op_ne.cpp
// compile with: /EHsc
#include <string>
#include <iostream>
int main( )
{
using namespace std;
// Declaring an objects of type basic_string<char>
string s1 ( "pluck" );
string s2 ( "strum" );
cout << "The basic_string s1 = " << s1 << "." << endl;
cout << "The basic_string s2 = " << s2 << "." << endl;
// Declaring a C-style string
char *s3 = "pluck";
cout << "The C-style string s3 = " << s3 << "." << endl;
// First member function: comparison between left-side object
// of type basic_string & right-side object of type basic_string
if ( s1 != s2 )
cout << "The strings s1 & s2 are not equal." << endl;
else
cout << "The strings s1 & s2 are equal." << endl;
// Second member function: comparison between left-side object
// of type basic_string & right-side object of C-syle string type
if ( s1 != s3 )
cout << "The strings s1 & s3 are not equal." << endl;
else
cout << "The strings s1 & s3 are equal." << endl;
// Third member function: comparison between left-side object
// of C-syle string type & right-side object of type basic_string
if ( s3 != s2 )
cout << "The strings s3 & s2 are not equal." << endl;
else
cout << "The strings s3 & s2 are equal." << endl;
}
需求
標題: <string>
命名空間: std