64,648
社区成员
发帖
与我相关
我的任务
分享
string string::operator + (const string &other)
{
string stmp;
stmp.m_string = new char[strlen(m_string)+strlen(other.m_string)+1];
strcpy(stmp.m_string, m_string);
strcat(stmp.m_string, other.m_string);
return stmp;
}
string string::operator = (const string &other)
{
if (this->m_string == other.m_string)
{
return *this;
}
m_string = new char[strlen(other.m_string)+1];
strcpy(this->m_string,other.m_string);
return *this;
}
测试可用