int length = strlen(other.m_data);
m_data = new char[length+1]; // 若能加 null 判断则更好
strcpy(m_data, other.m_data);
}
// 赋值函数
string & string::operator =(const string &other) // 13分
{
// (1) 检查自赋值 // 4分
if(this == &other)
return *this;
// (2) 释放原有的内存资源 // 3分
delete [] m_data;