C++习题求解答!

2024-12-18 17:00:58
推荐回答(1个)
回答1:

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*/
};
核心代码,其它不懂追问。