I am studying C++. I am surprised that it can compare strings. The following code compiles and runs successfully for strings a and b.
if (b >= a)
{}
What does it mean?
I am studying C++. I am surprised that it can compare strings. The following code compiles and runs successfully for strings a and b.
if (b >= a)
{}
What does it mean?
All comparisons of std::string are lexicographical. See std::basic_string::operator>=.
You can find an excellent answer which explains this in detail here:
Using the less than comparison operator for strings. The operators < and >= are not equivalent, but the principle is the same.