CString Comparison Operators

Syntax

BOOL operator ==( const CString& s1, const CString& s2 );

BOOL operator ==( const CString& s1, const char* s2 );

BOOL operator ==( const char* s1, const CString& s2 );

BOOL operator !=( const CString& s1, const CString& s2 );

BOOL operator !=( const CString& s1, const char* s2 );

BOOL operator !=( const char* s1, const CString& s2 );

BOOL operator <( const CString& s1, const CString& s2 );

BOOL operator <( const CString& s1, const char* s2 );

BOOL operator <( const char* s1, const CString& s2 );

BOOL operator >( const CString& s1, const CString& s2 );

BOOL operator >( const CString& s1, const char* s2 );

BOOL operator >( const char* s1, const CString& s2 );

BOOL operator <=( const CString& s1, const CString& s2 );

BOOL operator <=( const CString& s1, const char* s2 );

BOOL operator <=( const char* s1, const CString& s2 );

BOOL operator >=( const CString& s1, const CString& s2 );

BOOL operator >=( const CString& s1, const char* s2 );

BOOL operator >=( const char* s1, const CString& s2 ) ;

Remarks

These comparison operators compare two CString objects, and they compare a CString object with an ordinary null-terminated C string. The operators are a convenient substitute for the case-sensitive Compare member function.

Return Value

TRUE if the strings meet the comparison condition; otherwise FALSE.

Example

CString s1( "abc" );

CString s2( "abd" );

ASSERT( s1 < s2 ); // Operator is overloaded for both

ASSERT( "ABC" < s1 ); // CString and char*

ASSERT( s2 > "abe" );