String t4("da huai dan");
t4 = "hello world";
String& String::operator=(char *p)
{
if (this->p != NULL)
{
delete[] this->p;
this->p = NULL;
this->len = 0;
}
this->len = strlen(p);
this->p = new char[this->len];
strcpy(this->p, p);
return *this;
}
String::~String()
{
if (this->p != NULL) {
delete [] this->p;
this->p = NULL;
this->len = 0;
}
cout << "一个 已经被释放" << endl;