关于重载运算符函数解决办法

关于重载运算符函数
#include <iostream>
using namespace std;
class String
{public:
String( ){p=NULL;}
String(char *str);
friend booloperator>(String &string1,String &string2);
friend booloperator<(String &string1,String &string2);
friend booloperator==(String &string1,String &string2);
void display( );
private:
char *p;
}; 
String∷String(char *str)
{p=str;}
void String∷display( ) // 输出p所指向的字符串
{cout<<p;}
booloperator>(String &string1,String &string2)
{if(strcmp(string1.p,string2.p)>0)
return true;
else
return false;
}
booloperator<(String &string1,String &string2)
{if(strcmp(string1.p,string2.p)<0)
return true;
else
return false;
}
booloperator==(String &string1,String &string2)
{if(strcmp(string1.p,string2.p)==0)
return true;
else
return false;
}
void compare(String &string1,String &string2)
{if(operator>(string1,string2)==1)
{string1.display( );cout<<″>″;string2.display( );}
else
if(operator<(string1,string2)==1)
{string1.display( );cout<<″<″;string2.display( );}
else
if(operator==(string1,string2)==1)
{string1.display( );cout<<″=″;string2.display( );}
cout<<endl;
}
intmain( )
{String string1(″Hello″),string2(″Book″),string3(″Computer″),string4(″Hello″);
compare(string1,string2);
compare(string2,string3);
compare(string1,string4);
return 0;
}
运行结果为
Hello>Book
Book<Computer
Hello==Hello




在compare函数中,operator>是作为一个整体,作为一个函数名来出现的吗,还可以这样用?
------解决方案--------------------
这是显式调用重载函数,就像调用普通函数一样,当然你可以写为 

if
(string1>string2)
------解决方案--------------------
不需要带上operator关键字了吧!已经重载了,可以直接用相关的运算符号了!