Uwaga
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Sprawdza, czy obiekt string po lewej stronie operatora nie równa się obiekt string po prawej stronie.
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
);
Parametry
_Left
Ciąg stylu C lub obiektu typu basic_string ma być porównywana._Right
Ciąg stylu C lub obiektu typu basic_string ma być porównywana.
Wartość zwracana
TRUE Jeśli obiekt string po lewej stronie operatora nie jest równa leksykograficznym obiektu ciąg po prawej stronie; w przeciwnym razie false.
Uwagi
Porównanie między obiektami string jest oparty na parowania lexicographical porównanie ich znaków.Dwa ciągi znaków są równe, jeśli mają taką samą liczbę znaków i ich odpowiednich znaków wartości są takie same.W przeciwnym razie są nierówne.
Przykład
// 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;
}
Wymagania
Nagłówek: <ciąg>
Przestrzeń nazw: std