单选题 有如下程序: #include<iostream> #include<cstring> using namespace std; class MyString { public: char str[80]; MyString(const char*s){strcpy(str,s);} MyString&operator+=(MySring a){ strcat(str,a.str); return*this; } }; ostream&operator<<(ostream&s,const MyString&z){return s<<z.str;} int main(){ MyString x(''abe''),y(''ede''); eout<<(x+=y)<<end1; return 0; } 运行这个程序的输出结果是( )。
【正确答案】 D
【答案解析】解析:在类MyString中,定义了带参数的构造函数MyString(const char*s),其作用是把s指向的字符串拷贝到字符组str中。在类中还对运算+=进行重载定义,其作用是把字符串s仃和a相连接并赋给str,所以在主函数中执行x+=y时,结果为abccde。