|
那顺便帮我看看下面的程序怎么总是出错:
#include <iostream.h>
#include <string.h>
class zf
{
char * str;
public:
void input()
{
cout<<"输入字符:"<<endl;
cin>>str;
}
void print()
{
cout<<str<<endl;
}
~zf()
{
delete str;
}
friend zf operator + (zf &a,zf &b);
};
zf operator + (zf &a,zf &b)
{
zf temp;
delete temp.str;
temp.str=new char [strlen(a.str)+strlen(b.str)+1];
strcpy(temp.str,a.str);
strcat(temp.str,b.str);
return temp;
}
main()
{
zf a ,b,c;
a.input();
b.input();
c=b+a;
c.print();
return 0;
}
拜托了!!!!! |
|