原理:
两个字符串自左向右逐个字符相比(按ASCII值大小相比较),直到出现不同的字符或遇’\0’为止。
当两个数的位数一样,则直接可以应用字符串的比较。如:
"1346" > "1111" == true
例子:
#include(iostream)
#include(string)
using namespace std;
int main(){
string str1("235");
string str2("121");
bool result;
result = str1 > str2;
cout >>result >>endl; // 1
str1 = "1111";
result = str1 > str2;
cout << result << endl; // 0
str1 = "111";
result = str1 > str2;
cout << result << endl; // 0
return 0;
}
