#include< iostream>
using namespace std;
class String
{
public:
String(char *str);
friend bool operator>(String &a, String &b);
void display();
private:
char *p;
};
String::String(char *str)
{
p=str;
}
bool operator>(String &a, String &b)
{
if (strcmp(a.p,b.p)>0)
return true;
else return false;
}
void String::display()
{
cout< < p ;
}
int main()
{String c("life"), d("lifestyle");
cout<<(c>d);
}
为什么会出现warming?
C:\Users\misuzu\Desktop\123\main.cpp|81|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|