试题六(共15分)阅读下列说明和C++代码,填补代码中的空缺,将解答填入答题纸的对应栏内。【说明】以下C++代码实现一个简单的聊天室系统(ChatRoomSystem),多个用户(User)可以向聊天室(ChatRoom)发送消息,聊天室将消息展示给所有用户。类图如图6-1所表示。 【C++代码】#include<iostream>#include<string>usingnamespacestd;classUser{private:stringname;public:User(stringname){(1)=name;}~User(){} voidsetName(stringname){this->name=name;}stringgetName(){returnname;}voidsendMessage(stringmessage);};classChatRoom{.public:staticvoidshowMessage(User*user,stringmessage){cout<<"["<<user->getName()"]:"<<message<<endl;}};voidUser::sendMessage(stringmessage){(2)(this,message);}classChatRoomSystem{public:..voidstartup0(){User*zhang=newUser(“John");User*li=newUser("Leo"); zhang->sendMessage("Hi!Leo!");li_>sendMessage("Hi!John!");}voidjoin(User*user){(3)("HeIIoEveryone!lam"+user->getName());.;}.};intmain(){ChatRoomSystem*crs=(4);crs->startup();crs->join((5)("Wayne"));deletecrs;}/*程序运行结果:[John]:Hi!Leol[Leo]:Hi!John![Wayne】:HelloEveryone!IamWayne/*
1、this->name 2、ChatRoom::showMessage 3、user->sendMessage 4、new ChatRoomSystem() 5、new User