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

shopify独立站搭建电子商务平台

shopify独立站搭建,电子商务平台,让别人做一个网站需要多少钱,网络推广商城意图:将对象组成树状结构以表示“部分-整体”的层次结构,使得Client对单个对象和组合对象的使用具有一致性。 上下文:在树型结构的问题中,Client必须以不同的方式处理单个对象和组合对象。能否提供一种封装&#xff0c…

意图:将对象组成树状结构以表示“部分-整体”的层次结构,使得Client对单个对象和组合对象的使用具有一致性。

上下文:在树型结构的问题中,Client必须以不同的方式处理单个对象和组合对象。能否提供一种封装,统一简单元素和复杂元素的概念,让对象容器自己来实现自身的复杂结构,让Client可以像处理简单元素一样来处理复杂元素,从而使Client与复杂元素的内部结构解耦?

UML

在这里插入图片描述

Component:为Composite中的对象声明接口;在适当情况下,实现所有类公共接口的默认行为;声明一个接口,用于访问和管理Component的子部件;在递归结构中定义一个接口,用于访问一个父部件,并在适当的情况下实现它。
Leaf:在Composite中表示叶子对象。
Composite:存储子部件,并定义有子部件的那些部件的行为。
Client:通过Component接口操作Composite的对象。

在这里插入图片描述

代码:

#include <iostream>
#include <list>
using namespace std;class Component
{
public:string name;Component(string name):name(name){}virtual void add(Component *c) = 0;virtual void remove(Component *c) = 0;virtual void display(int depth) = 0;
};class Leaf:public Component
{
public:// Component interfaceLeaf(string name):Component(name){}
public:void add(Component *c);void remove(Component *c);void display(int depth);
};void Leaf::add(Component *c )
{(void)(c);//消除警告cout << "不能向叶子中添加Component" << endl;
}void Leaf::remove(Component *c)
{(void)(c);//Warningcout << "不能从叶子中删除Component" << endl;
}void Leaf::display(int depth)
{cout << string(depth,'-') << this->name << endl;
}class Composite:public Component
{
public:list<Component*> children;// Component interfaceComposite(string name):Component(name){}
public:void add(Component *c);void remove(Component *c);void display(int depth);
};
void Composite::add(Component *c)
{children.push_back(c);
}void Composite::remove(Component *c)
{children.remove(c);
}void Composite::display(int depth)
{cout << string(depth,'-') << this->name << endl;list<Component*>::iterator it;for(it = children.begin();it != children.end();it++){Component *c = *it;c->display(depth + 2);}
}
int main()
{Composite *root = new Composite("树干");root->add(new Leaf("树叶1"));root->add(new Leaf("树叶2"));Composite *c1 = new Composite("树枝1");c1->add(new Leaf("树叶1-1"));c1->add(new Leaf("树叶1-2"));root->add(c1);Composite *c1_1 = new Composite("树枝1-1");c1_1->add(new Leaf("树叶1-1-1"));c1_1->add(new Leaf("树叶1-1-2"));c1->add(c1_1);root->add(new Leaf("树叶3"));root->display(1);return 0;
}

结果

-树干
---树叶1
---树叶2
---树枝1
-----树叶1-1
-----树叶1-2
-----树枝1-1
-------树叶1-1-1
-------树叶1-1-2
---树叶3
http://www.hkea.cn/news/8503/

相关文章:

  • 洞头网站建设谷歌seo工具
  • 什么网站做外贸最好公司做网站需要多少钱
  • 嘉兴网站建设方案外包百度快照和广告的区别
  • 怎么做一淘宝客网站吗常用的网络推广方式有哪些
  • 寿光网站建设公司百度引擎搜索入口
  • 哪里能做网站南宁百度推广代理商
  • 深圳软件定制开发公司排行温州seo结算
  • 坂田网站建设推广公司石家庄百度推广优化排名
  • 手机网站建设新闻百度资源提交
  • 建设网站功能定位传统营销
  • 网站页面构架seo排名哪家有名
  • banner设计网站重庆旅游seo整站优化
  • 网站建设中最基本的决策之一是网络营销师工作内容
  • 深圳建站的公司外包公司和劳务派遣的区别
  • 用java怎么做网站镇江seo快速排名
  • 深圳网站建设在哪里可以如何做优化排名
  • 棋牌网站建设源码营销策划主要做些什么
  • 网站在哪里备案5118站长工具
  • 杭州制作网站个人sem是什么的英文缩写
  • 如何做网站限制策略东莞免费建站公司
  • 资阳的网站建设域名seo站长工具
  • 网站如何做排名靠前福州关键词快速排名
  • 江西锐安建设工程有限公司网站磁力搜索引擎
  • 网站设计代码武汉推广服务
  • 二级建造师最好的网站太原网站建设谁家好
  • 山东省商务厅网站开发区管理处互联网整合营销推广
  • 网站建设推广平台市场营销实务
  • 六十岁一级a做爰片免费网站seo关键词排名公司
  • b2b商场网站建设黄页大全
  • 百度站长反馈中心培训网站