How does the boolean operators work on <string>?

What is happening behind the Boolean operators (<) and (>) when comparing two strings?

Is it logically like this?
string Word1 = char Word1[10]..where Word1[0] = 'A';... and so on.
string Word2 = char Word2[7]..where Word2[0] = 'A';... and so on.

So when it compares using Boolean operators it converts Word1[0] = 'A' into its ASCII decimal value of 65, same for Word2[0];

find there equal (65 == 65), so moves to next character.

Word1[1] = "a"; ASCII 97
Word2[1] = "b"; ASCII 98

if(97 > 98) false;
if(97 < 98) true; returns the second cout statement.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <string>

int main(){

std::string Word1 = "Aardvark's";
std::string Word2 = "Abandon";
 
//How specifically are the Boolean operator's working below?
if (Word1 > Word2) std::cout << Word1 << " > " << Word2 << std::endl;
if (Word1 < Word2) std::cout << Word1 << " < " << Word2 << std::endl;

return 0;
}


Thanks for the help!
Topic archived. No new replies allowed.