MyString::MyString(const char* p)
{
if (p == NULL)
cpBody[0] = '\\0';
else
strncpy(cpBody, p, 80);
}
MyString::MyString(int i)
{ int j;
for (j = 0; j < i && j < 80; j++)
cpBody[j] = ' ';
cpBody[j] = '\\0';
}
MyString::MyString(MyString& s)
{ *this=s;
/* 或者改用如下语句:int length;
length=strlen(s.cpBody);
for(int i=0;
i
}
MyString& MyString::operator[](int i)
{ static MyString s;
int j;
s = *this;
for (j = i; cpBody[j] != '\\0'; j++)
s.cpBody[j-i] = s.cpBody[j];
s.cpBody[j-i] = '\\0';
return s;
}
MyString& operator+(int N, MyString& s)
{ static MyString st;
int i,length;
length=strlen(s.cpBody);
for(i=0;i
s.cpBody[length+i]=s.cpBody[length-1];
s.cpBody[length+i]='\\0';
st=s;