重载的一个类似于C++中的string
#include<iostream>
using namespace std;
class String{
public:
char *p;
String(){
p = NULL;
}
String(char *str){
p = str;
}
int size(){
return (sizeof(p)/sizeof(char));
}
};
bool operator > (String &a,String &b){
if(strcmp(a.p,b.p) == 1)
return true;
return false;
}
bool operator < (String &a,String &b){
if(strcmp(a.p,b.p) == -1)
return true;
return false;
}
bool operator == (String &a,String &b){
if(strcmp(a.p,b.p) == 0)
return true;
return false;
}
int main(void){
String s1("henuzxy"),s2("henulqs");
cout << s1.size() << endl;
if(s1 > s2){
cout << "OK" << endl;
}
else
cout << "NO" << endl;
return 0;
}