标签:输入参数 his 引用 int size har operator 检查 delete
String & String::operator =(const String &other){ // 得分点:输入参数为const型
if(this == &other) //得分点:检查自赋值
return *this;
delete [] m_data; //得分点:释放原有的内存资源
int length = strlen( other.m_data );
m_data = new char[length+1]; //加分点:对m_data加NULL 判断
strcpy( m_data, other.m_data );
return *this; //得分点:返回本对象的引用
}
标签:输入参数 his 引用 int size har operator 检查 delete
原文地址:http://www.cnblogs.com/quan1/p/6696194.html