Comparison
Strings support the well-known comparison operators ==, !=, <, >, >=
. The comparison of two strings takes place on their elements.
// stringComparisonAndConcatenation.cpp
...
#include
<string>
...
std
::
string
first
{
"aaa"
};
std
::
string
second
{
"aaaa"
};
std
::
cout
<<
(
first
<
first
)
<<
std
::
endl
;
// false
std
::
cout
<<
(
first
<=
first
)
<<
std
::
endl
;
// true
std
::
cout
<<
(
first
<
second
)
<<
std
::
endl
;
// true