Freigeben über


operator>= (<string>)

Testet, ob das Zeichenfolgenobjekt auf der linken Seite des Operators größer oder gleich das Zeichenfolgenobjekt auf der rechten Seite ist.

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 
   );

Parameter

  • _Left
    E-ähnlich Zeichenfolge im C-Format oder ein Objekt des Typs zu vergleichende basic_string.

  • _Right
    E-ähnlich Zeichenfolge im C-Format oder ein Objekt des Typs zu vergleichende basic_string.

Rückgabewert

true, wenn das Zeichenfolgenobjekt auf der linken Seite des Operators lexikografisch größer oder gleich das Zeichenfolgenobjekt auf der rechten Seite ist; andernfalls false.

Hinweise

Ein lexikografischer Vergleich zwischen Zeichenfolgen vergleicht sie Zeichen bis von Zeichen:

  • Es werden zwei gleichwertige ungleiche Zeichen, und das Ergebnis des Vergleichs wird als Ergebnis des Vergleichs zwischen Zeichenfolgen ausgeführt.

  • Es findet keine Ungleichheiten, jedoch eine Zeichenfolge mit mehr Zeichen als die andere, und je kürzere Zeichenfolge als kleiner als gilt umso längere Zeichenfolge.

  • Es findet keine Ungleichheiten und durchsucht die Zeichenfolgen enthält die Anzahl von Zeichen und sodass die Zeichenfolgen gleich.

Beispiel

// string_op_ge.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

int main( ) 
{
   using namespace std;

   // Declaring an objects of type basic_string<char>
   string s1 ( "strict" );
   string s2 ( "strum" );
   cout << "The basic_string s1 = " << s1 << "." << endl;
   cout << "The basic_string s2 = " << s2 << "." << endl;

   // Declaring a C-style string
   char *s3 = "stricture";
   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 string s1 is greater than or equal to "
           << "the string s2." << endl;
   else
      cout << "The string s1 is less than "
           << "the string s2." << endl;

   // Second member function: comparison between left-side object
   // of type basic_string & right-side object of C-syle string type
   if ( s3 >= s1 )
      cout << "The string s3 is greater than or equal to "
           << "the string s1." << endl;
   else
      cout << "The string s3 is less than "
           << "the string s1." << endl;

   // Third member function: comparison between left-side object
   // of C-syle string type & right-side object of type basic_string
   if ( s2 >= s3 )
      cout << "The string s2 is greater than or equal to "
           << "the string s3." << endl;
   else
      cout << "The string s2 is less than "
           << "the string s3." << endl;
}
  

Anforderungen

Header: <Zeichenfolge>

Namespace: std

Siehe auch

Referenz

string::operator>=