# include # include # include "string.h" void strcopy(string& dest,string& src) { int i=0; while(src.st[i]!='\0') { dest.st[i]=src.st[i]; i++; } dest.st[i]=src.st[i]; dest.len=src.len; } string::string(char *str) { if(strlen(str)<1000) { len=strlen(str); st=new char[len+1]; strcpy(st,str); } else cout<<"There is not enough memory\n"; } void string:: change(char *str) { if(strlen(str)<1000) { delete [len+1]st; len=strlen(str); st=new char[len+1]; strcpy(st,str); } else cout<<"There is not enough memory\n"; } void string::show() { cout<=0 && i>(istream& in, string& s) { char buffer[302]; in.getline(buffer,300); s.change(buffer); return in; } string& string:: operator=(const string& rhs) { if(this==&rhs) return *this; this->len=rhs.len; this->change(rhs.st); return *this; } string string::operator+(const string& rhs) { string tmp; tmp.len=this->len +rhs.len+1; tmp.change(this->getst()); tmp+=rhs; return tmp; } string& string::operator+=(const string& rhs) { this->strcats(rhs.getst()); }