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

网站加入谷歌地图导航推广普通话手抄报模板可打印

网站加入谷歌地图导航,推广普通话手抄报模板可打印,wordpress怎么加关键词和描述,网页开发环境一般写什么组合模式定义 C组合模式#xff08;Composite Pattern#xff09;是一种结构型设计模式#xff0c;他允许将对象组合成树形结构来表示“部分-整体”的层次结构#xff1b;在组合模式中有两种基本类型的对象#xff1a;叶子对象和组合对象#xff0c;叶子对象时没有子对象…组合模式定义 C组合模式Composite Pattern是一种结构型设计模式他允许将对象组合成树形结构来表示“部分-整体”的层次结构在组合模式中有两种基本类型的对象叶子对象和组合对象叶子对象时没有子对象的而组合对象则是拥有子对象的。叶子对象和组合对象都实现了相同的接口以便可以用相同的方式处理他们。 简单的C组合模式实例 #include iostream #includevector//抽象基类定义组合对象和叶子对象的公共接口 class Component { public://纯虚函数需要子类实现,virtual void operation() 0; };//叶子对象无子对象实现Component接口 class Leaf :public Component { public:void operation() override{std::cout Lead operation std::endl;} }; //组合对象拥有子对象实现Component接口 class Composite :public Component { public://添加子对象到子对象列表中void add(Component* component){children.push_back(component);}void operation() override{std::cout Composite operation std::endl;for (auto child : children){child-operation();}} private:std::vectorComponent*children; //子对象列表 }; int main() {Leaf leaf;Composite composite;composite.add(leaf);composite.add(leaf);composite.add(leaf);composite.operation();return 0;}文件系统来演示组合模式 我们以一个文件系统为例使用组合模式来表示文件系统中的目录和文件的关系 #include iostream #includestring #includevector//抽象基类定义了组合对象和叶子对象的公共接口 class FileSystemComponent { public:virtual void showInfo() 0;virtual ~FileSystemComponent() {}; }; //叶子对象:文件 class File :public FileSystemComponent { public:File(const std::string name) :m_Name(name) {}void showInfo() override{std::cout File: m_Name std::endl;} private:std::string m_Name; };//组合对象:目录 class Directory :public FileSystemComponent { public:Directory(const std::string name) :m_Name(name) {}void add(FileSystemComponent* com){children.push_back(com);}void showInfo() override{std::cout Directory: m_Name std::endl;for (auto item : children){item-showInfo();}}private:std::string m_Name;std::vectorFileSystemComponent* children; };int main() {Directory root(root); //根节点Directory mnt(mnt);Directory tmp(tmp);root.add(mnt);root.add(tmp);File ext(ext);File nfs(nfs);mnt.add(ext);tmp.add(nfs);root.showInfo();return 0;}在这里插入图片描述
http://www.w-s-a.com/news/449678/

相关文章:

  • 学校网站建设制度网站相关推荐怎么做
  • 昌图网站wordpress 视频外链
  • 企业网站要怎么建设重庆住房城乡建设部网站
  • html5网站特点seo教程培训班
  • 深圳网站建设哪个最好网站 多语
  • 互联网工具型网站创意网络广告
  • 影视公司网站建设网页界面设计分辨率是多少dpi
  • 免费的做微博的网站模板wordpress 页面 首页
  • 摄影图片网站网站辅导运营与托管公司
  • 做课件的网站长春免费建站模板
  • 响应式网站模板下载免费wordpress 小工具移动
  • 网站标签title在线app制作平台
  • 做电器推广的网站简洁大方的网站模板
  • 网站开发的平台100个详情页设计图
  • wordpress淘宝客建站教程视频知名的设计公司网站
  • 批量做单页网站怎么直接用代码做网站
  • 百度收录较好的网站办公室装修设计方案
  • 建设购物网站要求cnzz数据统计
  • 深圳自适应网站建设价格广东网站建设软件
  • 网页设计介绍北京网站自己做彩票网站
  • 最牛论坛网站app生成链接
  • 用jsp做的网站源代码网站优化说明
  • 网站建设公司名字甘肃省和住房建设厅网站
  • 做外贸网站需要什么卡网站建设公司怎样
  • 网站关键词密度怎么计算的中文版wordpress
  • asp网站建设教程如何在线上推广自己的产品
  • 电脑网站你懂我意思正能量济南网站建设公司熊掌号
  • 杂志社网站建设萧山区网站建设
  • 电商网站前端制作分工网站怎做百度代码统计
  • 免费的html大作业网站网站开发心得500字