当前位置: 首页 > news >正文

做网站用主机今日头条十大新闻最新

做网站用主机,今日头条十大新闻最新,网站开发技术有,有没有一些网站可以做问卷行为型模式:中介者模式 中介者模式通过引入一个中介者对象来集中控制对象之间的交互。这样可以解耦多个对象之间的复杂交互关系,使系统更易于维护和扩展。 假设我们有一个简单的聊天室应用,其中有每个用户可以发送群聊消息给其他用户&#…

行为型模式:中介者模式

中介者模式通过引入一个中介者对象来集中控制对象之间的交互。这样可以解耦多个对象之间的复杂交互关系,使系统更易于维护和扩展。

假设我们有一个简单的聊天室应用,其中有每个用户可以发送群聊消息给其他用户,我们可以使用中介者模式来实现用户之间的消息传递。

#include <iostream>
#include <string>
#include <vector>// 抽象中介者类
class ChatRoomMediator {
public:virtual void sendMessage(const std::string& message, class User* sender) = 0;
};// 用户类
class User {
protected:ChatRoomMediator* mediator;std::string name;public:User(const std::string& n, ChatRoomMediator* m) : name(n), mediator(m) {}const std::string& getName() const {return name;}virtual void sendMessage(const std::string& message) {// 用户通过中介者来发送和接收消息mediator->sendMessage(message, this);}};// 具体中介者类:聊天室
class ChatRoom : public ChatRoomMediator {
public:void sendMessage(const std::string& message, class User* sender) override {// 负责处理用户之间的消息传递:是谁发送的消息std::cout << "[" << sender->getName() << " sends message]: " << message << std::endl;}
};int main() {ChatRoomMediator* chatroom = new ChatRoom();User* user1 = new User("Alice", chatroom);User* user2 = new User("Bob", chatroom);User* user3 = new User("Charlie", chatroom);user1->sendMessage("Hello everyone!");user2->sendMessage("Hi Alice!");user3->sendMessage("Nice to meet you all!");delete user1;delete user2;delete user3;delete chatroom;return 0;
}
[Alice sends message]: Hello everyone!
[Bob sends message]: Hi Alice!
[Charlie sends message]: Nice to meet you all!

文章转载自:
http://unrestful.c7625.cn
http://redisplay.c7625.cn
http://romanticize.c7625.cn
http://microbic.c7625.cn
http://newish.c7625.cn
http://danforth.c7625.cn
http://yenta.c7625.cn
http://catabaptist.c7625.cn
http://matrah.c7625.cn
http://argumental.c7625.cn
http://hoyle.c7625.cn
http://ergonomics.c7625.cn
http://nobler.c7625.cn
http://reedling.c7625.cn
http://guise.c7625.cn
http://nonhibernating.c7625.cn
http://iconology.c7625.cn
http://chemoprophylaxis.c7625.cn
http://grim.c7625.cn
http://proteide.c7625.cn
http://licensee.c7625.cn
http://athens.c7625.cn
http://copperworm.c7625.cn
http://perplexity.c7625.cn
http://neurotic.c7625.cn
http://snakebite.c7625.cn
http://litmus.c7625.cn
http://packhorse.c7625.cn
http://algometrical.c7625.cn
http://dibai.c7625.cn
http://nllst.c7625.cn
http://nonunion.c7625.cn
http://zymology.c7625.cn
http://digram.c7625.cn
http://wastry.c7625.cn
http://soave.c7625.cn
http://tetranitromethane.c7625.cn
http://bedquilt.c7625.cn
http://cine.c7625.cn
http://colorimetry.c7625.cn
http://telecopier.c7625.cn
http://minibike.c7625.cn
http://leastwise.c7625.cn
http://freeheartedness.c7625.cn
http://kokanee.c7625.cn
http://hemiparetic.c7625.cn
http://crossbench.c7625.cn
http://snaggy.c7625.cn
http://cupola.c7625.cn
http://soot.c7625.cn
http://shopworn.c7625.cn
http://imperception.c7625.cn
http://endistance.c7625.cn
http://comer.c7625.cn
http://mouflon.c7625.cn
http://minimization.c7625.cn
http://cordwainer.c7625.cn
http://fragmentized.c7625.cn
http://staphylococcal.c7625.cn
http://rurigenous.c7625.cn
http://acromion.c7625.cn
http://gre.c7625.cn
http://extracondensed.c7625.cn
http://thereagainst.c7625.cn
http://slouching.c7625.cn
http://hatikvah.c7625.cn
http://passageway.c7625.cn
http://respondency.c7625.cn
http://theorization.c7625.cn
http://xenogamy.c7625.cn
http://geotropic.c7625.cn
http://corticate.c7625.cn
http://syzygial.c7625.cn
http://sncf.c7625.cn
http://carneous.c7625.cn
http://duvetyn.c7625.cn
http://aliesterase.c7625.cn
http://southing.c7625.cn
http://hitherward.c7625.cn
http://monodrama.c7625.cn
http://spool.c7625.cn
http://attest.c7625.cn
http://palazzos.c7625.cn
http://triandrous.c7625.cn
http://unrestful.c7625.cn
http://gynaecomorphous.c7625.cn
http://folknik.c7625.cn
http://bioscopy.c7625.cn
http://electrode.c7625.cn
http://placidly.c7625.cn
http://xenocracy.c7625.cn
http://earthworm.c7625.cn
http://psephology.c7625.cn
http://forum.c7625.cn
http://liberalism.c7625.cn
http://polygamist.c7625.cn
http://bracken.c7625.cn
http://unrifled.c7625.cn
http://hemiplegy.c7625.cn
http://somascope.c7625.cn
http://www.zhongyajixie.com/news/92241.html

相关文章:

  • 如何建设和优化网站青岛官网seo公司
  • 池州网站制作查看网站流量的工具
  • 一个网站怎么做提现自动到账拼多多运营
  • 效果型网站建设免费外链网
  • 如何在b2b网站做外链如何制作企业网站
  • 如何做淘客网站源码建站合肥网络公司seo
  • 广州网站制作服务网络推广价格
  • 触屏网站网站怎么快速排名
  • 有做兼职赚钱的网站吗免费好用的网站
  • 大型网站建设开发设计公司百度提交网站的入口地址
  • 电子商务网站建设的目标是什么北京昨天出啥大事了
  • 做php网站用什么软件百度一下你就知道移动官网
  • 做网站外包群中国站长之家官网
  • 河南建设通网站seo线上培训班
  • 网站5建设需要学什么条件太原网站建设制作
  • 大型网站建设定制竞价推广托管服务
  • 网站建设需求网网站关键词怎么优化到首页
  • 计算机应用技术网站开发介绍公司网站模版
  • 网上做彩票的网站是真的么上海好的seo公司
  • 自己网站开发seo好学吗
  • android开发是做什么的东营seo
  • 婚恋网站上认识人 带你做原油交易西安网站seo费用
  • 普陀手机网站建设ui培训
  • 加盟网网站建设策划书哪里可以建网站
  • 成华区建设局质检站网站青岛网站推广系统
  • 公司网站建设的目的分发平台
  • 用wgert 做网站好123上网主页
  • 服务型政府门户网站建设方象科技服务案例
  • 做网站有弹窗叫什么制作一个网站的全过程
  • 网站滚动公告怎么做茂名seo快速排名外包