#include
#include
using namespace std;
class String
{
public:
String() { p = NULL; }
String(char str[]);
friend bool operator>(String &string1, String &string2);
private:
char *p;
};
String::String(char str[])
{
p = &str[];
}
bool operator> (String &string1, String &string2)
{
if (strcmp(string1.p, string2.p)>0)
return true;
else return false;
}
int main()
{
String string1("1234"),string2("22");
cout << (string1 > string2) << endl;
}
最终提示无法将参数一中的const char[3]转换成char,同样的参数2也是同样的错误,我这个程序没有用到const常量,这是从哪里蹦出来的呢?如何更改,求大神指点