operator== (<string>)
연산자의 왼쪽에서 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 이면 연산자의 왼쪽에 문자열 개체 사전순 문자열 개체 오른쪽; 같으면 그렇지 않으면 거짓.
설명
String 개체 간의 비교는 pairwise에서 기반으로 해당 문자가 사전순으로 비교 합니다.가 같은 수의 문자 및 해당 문자 값의 경우 두 개의 문자열이 같은지.그렇지 않으면 두 개체는 서로 다른 개체입니다.
예제
// string_op_eq.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 equal." << endl;
else
cout << "The strings s1 & s2 are not 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 equal." << endl;
else
cout << "The strings s1 & s3 are not 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 equal." << endl;
else
cout << "The strings s3 & s2 are not equal." << endl;
}
요구 사항
헤더: <string>
네임 스페이스: std