c++ 求助string类的测试问题
bool operator==(const String &a, const String &b){
return !strcmp(a.str, b.str);
}
bool operator>(const String &a, const String &b){
return strcmp(a.str, b.str) > 0;
}
bool operator>=(const String &a, const String &b){
return strcmp(a.str, b.str) >= 0;
}
还有
char & String::operator[](int n){
return str[n];
}
main函数怎么写来测试对错?
[解决办法]
就直接写不就好了么 string str1,str2;
if(str1==str2)...
if(str1>str2)...
for ( int n=0 ; n<str.getlength() ; n++ )
printf("%c",str1[n]) ;