Preview:
std::string test1 = "Baked";
std::string test2 = "Bake";  
bool compare = test1 < test2;
 
// Output: 0
/* Reason: There is no difference until the last letter so then it will compare the last letter with the blank space. 
Since blank space comes first before the letter d, this means that test1 is not less than test2 and that is why it returns false.*/
 
std::string test1 = "Baker";
std::string test2 = "Bdke";  
bool compare = test1 < test2;
 
// Output: 1
/* Reason: There is no difference until the second letter so then it will compare the second letter with the second letter of the other word.
Since the letter a comes first before the letter d, this means that test1 is less than test2 and that is why it returns true.*/
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter