📄 13-6.cpp
字号:
#include<iostream.h>
#include<string.h>
class string
{
char str[50];
public:
string()
{
*str='\0';
}
string(char *ptr){strcpy(str,ptr);}
char *get_str(){return str;}
int operator<(string s2);
int operator>(string s2);
int operator==(string s2);
};
int string::operator<(string s2)
{
return strcmp(str,s2.str)<0;
}
int string::operator>(string s2)
{
return strcmp(str,s2.str)>0;
}
int string::operator==(string s2)
{
return strcmp(str,s2.str)==0;
}
main()
{
string op1("Hello"),op2("There"),op3("Hello");
if(op1==op3)cout<<"op1 equals op3\n";
if(op1>op2)cout<<"op1>op2\n";
if(op1<op2)cout<<"op1<op2\n";
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -