# include <iostream.h>class string{private: char *str;public: string(char *s=""); string operator + (string &s); void show();};
# include "string.h"string::string(char *s){str=s;}void string::show(){ cout<<str<<endl;}string string::operator + (string &s){ char *t1=new char,*t2=t1,*s1=this->str,*s2=s.str; while(*s1!='\0') { *t1=*s1;t1++;s1++; } while(*s2!='\0') { *t1=*s2;t1++;s2++; } *t1='\0'; string t(t1); return t;}void main(){ string s1("zhang"),s2("jiang"),s3; s3=s1+s2; s1.show(); s2.show(); s3.show();}
运行结果为这个,怎么回事不显示S3啊?