首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++ string类的测试有关问题

2012-06-03 
c++ 求助string类的测试问题bool operator(const String &a, const String &b){return !strcmp(a.str, b

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]) ;

热点排行