class Person
{
public:
char *name;
/* other filed*/
Person& operator=(const Person& x){
int at_len = strlen(x->name);
delete x->name;
this->name = (char*)new char(at_len);
strcpy(this->name, x->name, at_len);
/* other filed copy*/
return *this;
}
/*other method*/
};
核心代码,其它不懂追问。