verb(char *i)
{
leng=strlen(i);
str=new char[leng+1];
strcpy(str,i);
}
~verb(){delete [] str;} //为什么要在这里delete [] str?????
verb operator+(const verb &a) {
verb t;
t.leng=leng+a.leng;
t.str=new char[t.leng+1]; //为什么 不能写成t.str=new char[t.leng] ?
strcpy(t.str,str);
strcat(t.str,a.str);
return t;
}
verb& operator=(const verb &a)
{
leng=a.leng;
delete []str; //为什么要释放str空间???
str=new char[leng+1];
strcpy(str,a.str);
return *this;
上面这些我反复思考却得不到合理的解释,请您指点一下好吗??辛苦了!!!