#include <iostream>
#include <cstring>using namespace std;
class myString
{private:char *str; //记录c风格的字符串int size; //记录字符串的实际长度public://无参构造myString():size(10){str = new char[size]; //构造出一个长度为10的字符串strcpy(str,""); //赋值为空串}//有参构造myString(const char *s) //string s("hello world"){size = strlen(s);str = new char[size+1];strcpy(str, s);}//拷贝构造myString(const myString &s):str(new char [s.size+1]),size(s.size){strcpy(this->str,s.str);}//析构函数~myString(){delete []str;str=nullptr;cout<<"析构完成"<<endl;}//拷贝赋值函数myString &operator=(const myString &s){this->size=s.size;this->str=new char[this->size+1];strcpy(this->str,s.str);return *this;}//判空函数bool empty(){return *(str)==0?true:false;}//size函数int getsize(){return size;}//c_str函数char* &c_str(){return str;}//at函数char &at(int pos){return *(str+pos);}//加号运算符重载myString operator+(const myString &R){this->size+=R.size;strcat(this->str,R.str);return *this;}//加等于运算符重载myString &operator+=(const myString &R){this->size+=R.size;strcat(this->str,R.str);return *this;}//[]重载char &operator[](int pos){return str[pos];}//>重载bool myString :: operator>(const myString &s)const{return strcmp(str,s.str)>0;}//>=重载bool myString :: operator>=(const myString &s)const{return strcmp(str,s.str)>=0;}//<重载bool myString :: operator<(const myString &s)const{return strcmp(str,s.str)<0;}//<=重载bool myString ::operator<=(const myString &s)const{return strcmp(str,s.str)<=0;}//==重载bool myString ::operator==(const myString &s)const{return strcmp(str,s.str)==0;}//!=重载bool myString ::operator!=(const myString &s)const{return strcmp(str,s.str)>0;}