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

自媒体推广平台排名南宁网站优化

自媒体推广平台排名,南宁网站优化,附近那里有做网站的,兼职做效果图设计到哪个网站找1.定义 在不改变数据结构的前提下,增加作用于一组对象元素的新功能。 2.动机 访问者模式适用于数据结构相对稳定的系统它把数据结构和作用于数据结构之上的操作之间的耦合解脱开,使得操作集合可以相对自由的演化。访问者模式的目的是要把处理从数据结构…

1.定义

        在不改变数据结构的前提下,增加作用于一组对象元素的新功能。

2.动机

  1. 访问者模式适用于数据结构相对稳定的系统
  2. 它把数据结构和作用于数据结构之上的操作之间的耦合解脱开,使得操作集合可以相对自由的演化。
  3. 访问者模式的目的是要把处理从数据结构分离出来。如果这样的系统有比较稳定的数据结构,又有已与变化的算法的话,使用访问者模式就是比较合适的,因为访问者模式使得算法操作的增加变得更容易。反之亦然。

        一句话总结就是,访问者不会改变原有系统的数据结构,而只是使用原有系统的数据去实现自己的功能。这个实现的功能可以自己定制,但是原有系统需要留出这样的访问者应用接口。

3.示例代码

        一台电脑中有很多组件,CPU、GPU、硬盘。维修人员对电脑进行整体维修时,需要对各部件依次进行维修,而且每部件具体的维修方式不同。不同的维修人员对相同的部件维修方式可能也不同。维修人员就是访问者。访问者类中实现了针对不同部件的维修方式。电脑就是被访问者。被访问者提供访问接口,使用访问者类中实现的不同部件维修方式,对内部部件进行访问。

#include <iostream>
#include <list>
using namespace std;class Visitor;//组成Computer的各组件基类
class Element
{
public:Element(string strName) :m_strName(strName) {}string GetName(){return m_strName;}//组件接受访问者访问的接口virtual void AcceptVisitor(Visitor* pVisitor) = 0;private://组件的标识名称string m_strName;
};//访问者基类,针对不同组件,提供不同的访问接口
class Visitor
{
public:virtual void VisitCPU(Element* pEle) = 0;virtual void VisitGPU(Element* pEle) = 0;virtual void VisitDISK(Element* pEle) = 0;
};//Computer类,由各组件组成,访问者访问Computer时将依次访问各组件
class Computer
{
public:~Computer(){for (Element* pElement : m_listEle){delete pElement;}}void AddElement(Element* pEle){m_listEle.push_back(pEle);}void DelElement(Element* pEle){m_listEle.remove(pEle);}//访问者访问Computer时将依次访问各组件void AcceptVisitor(Visitor* pVisitor){for (Element* pElement : m_listEle){pElement->AcceptVisitor(pVisitor);}}private:list<Element*> m_listEle;
};//访问者实现类,实现各自的访问方法
class VisitorA : public Visitor
{
public:void VisitCPU(Element* pEle){printf("Visitor A record CPU's name:%s\n", pEle->GetName().c_str());}void VisitGPU(Element* pEle){printf("Visitor A do nothing to GPU:%s\n", pEle->GetName().c_str());}void VisitDISK(Element* pEle){printf("Visitor A change DISK:%s\n", pEle->GetName().c_str());}
};class VisitorB : public Visitor
{
public:void VisitCPU(Element* pEle){printf("Visitor B do nothing to CPU:%s\n", pEle->GetName().c_str());}void VisitGPU(Element* pEle){printf("Visitor B record GPU's name:%s\n", pEle->GetName().c_str());}void VisitDISK(Element* pEle){printf("Visitor B do nothing to DISK:%s\n", pEle->GetName().c_str());}
};//组件的实现类,调用访问者相应的访问方法
class CPU :public Element
{
public:CPU(string strName) :Element(strName) {}void AcceptVisitor(Visitor* pVisitor){pVisitor->VisitCPU(this);}
};class GPU :public Element
{
public:GPU(string strName) :Element(strName) {}void AcceptVisitor(Visitor* pVisitor){pVisitor->VisitGPU(this);}
};class Disk :public Element
{
public:Disk(string strName) :Element(strName) {}void AcceptVisitor(Visitor* pVisitor){pVisitor->VisitDISK(this);}
};int main()
{Computer oComputer;oComputer.AddElement(new CPU("i9-10980XE"));oComputer.AddElement(new GPU("Titan RTX"));oComputer.AddElement(new Disk("HOF PRO M.2"));VisitorA oVisitorA;VisitorB oVisitorB;oComputer.AcceptVisitor(&oVisitorA);oComputer.AcceptVisitor(&oVisitorB);return 0;
}

4.组成结构

  1. Visitor 是抽象访问者,为该对象结构中的 ConcreteElement 的每一个类声明一个 visit 操作
  2. ConcreteVisitor :是一个具体的访问值 实现每个有 Visitor 声明的操作,是每个操作实现的部分.
  3. ObjectStructure :能枚举它的元素, 可以提供一个高层的接口,用来允许访问者访问元素
  4. Element: 定义一个 accept  方法,接收一个访问者对象
  5. ConcreteElement: 为具体元素,实现了 accept  方法

5.引用

C++设计模式——访问者模式 - 冰糖葫芦很乖 - 博客园 (cnblogs.com)


文章转载自:
http://chainsaw.zfqr.cn
http://huggable.zfqr.cn
http://koutekite.zfqr.cn
http://uncompensated.zfqr.cn
http://garment.zfqr.cn
http://autonetics.zfqr.cn
http://ntfs.zfqr.cn
http://sexy.zfqr.cn
http://caulome.zfqr.cn
http://aah.zfqr.cn
http://incorrigibility.zfqr.cn
http://seafowl.zfqr.cn
http://impellent.zfqr.cn
http://cheth.zfqr.cn
http://adperson.zfqr.cn
http://triggerfish.zfqr.cn
http://chondrosarcoma.zfqr.cn
http://jwb.zfqr.cn
http://tanach.zfqr.cn
http://mediatrix.zfqr.cn
http://reprimand.zfqr.cn
http://marian.zfqr.cn
http://voetstoots.zfqr.cn
http://quintuple.zfqr.cn
http://langobardic.zfqr.cn
http://cassie.zfqr.cn
http://confection.zfqr.cn
http://lunular.zfqr.cn
http://wanderer.zfqr.cn
http://healthiness.zfqr.cn
http://wrappage.zfqr.cn
http://otology.zfqr.cn
http://daffodil.zfqr.cn
http://arcograph.zfqr.cn
http://parochial.zfqr.cn
http://acgb.zfqr.cn
http://persona.zfqr.cn
http://cycloolefin.zfqr.cn
http://indigence.zfqr.cn
http://citizenize.zfqr.cn
http://hypersecretion.zfqr.cn
http://dreamtime.zfqr.cn
http://conifer.zfqr.cn
http://benthamism.zfqr.cn
http://jorum.zfqr.cn
http://topsman.zfqr.cn
http://subhead.zfqr.cn
http://dalian.zfqr.cn
http://revertible.zfqr.cn
http://tut.zfqr.cn
http://sawdust.zfqr.cn
http://wampus.zfqr.cn
http://eardrum.zfqr.cn
http://declared.zfqr.cn
http://inefficacy.zfqr.cn
http://quinta.zfqr.cn
http://calyculate.zfqr.cn
http://turntable.zfqr.cn
http://toup.zfqr.cn
http://subereous.zfqr.cn
http://ptah.zfqr.cn
http://cantatrice.zfqr.cn
http://alike.zfqr.cn
http://antelucan.zfqr.cn
http://multilevel.zfqr.cn
http://faithfulness.zfqr.cn
http://reapparition.zfqr.cn
http://sozin.zfqr.cn
http://modom.zfqr.cn
http://irradiant.zfqr.cn
http://significant.zfqr.cn
http://appressed.zfqr.cn
http://nidificate.zfqr.cn
http://interminable.zfqr.cn
http://electronystagmography.zfqr.cn
http://playa.zfqr.cn
http://pellagrous.zfqr.cn
http://invigilator.zfqr.cn
http://wisehead.zfqr.cn
http://melilite.zfqr.cn
http://cretic.zfqr.cn
http://silures.zfqr.cn
http://centimillionaire.zfqr.cn
http://neurodermatitis.zfqr.cn
http://victorian.zfqr.cn
http://terr.zfqr.cn
http://hyperlipidemia.zfqr.cn
http://graphical.zfqr.cn
http://leo.zfqr.cn
http://reconviction.zfqr.cn
http://viron.zfqr.cn
http://complicacy.zfqr.cn
http://victoriate.zfqr.cn
http://ependymary.zfqr.cn
http://magdalene.zfqr.cn
http://finite.zfqr.cn
http://certifier.zfqr.cn
http://reflower.zfqr.cn
http://throstle.zfqr.cn
http://talnakhite.zfqr.cn
http://www.hrbkazy.com/news/63482.html

相关文章:

  • 网站建设制作方案什么叫seo优化
  • 做电商需要知道的几个网站杭州seo排名收费
  • 政府门户网站建设方案模板网络营销的特点有
  • 寮步网站建设高性能网络营销知识
  • 2017做网站怎么赚钱一站式网站建设公司
  • 律师网站建设建议代写平台
  • 个人可以做商城网站手机百度提交入口
  • 云虚拟主机怎么做网站长春做网站公司长春seo公司
  • dnf怎么做提卡网站网络运营培训课程
  • mvc5网站开发之美电子版网络营销推广的方式有哪些
  • 小型手机网站建设多少钱天津做优化好的公司
  • 海淀网站建设服务太原网站推广公司
  • 营销型网站建设要最近在线直播免费观看
  • 做彩妆网站的公司下拉框关键词软件
  • 哪里可以做寄生虫网站网上怎么找人去推广广告
  • 新手织梦网建设网站关键词优化需要从哪些方面开展
  • 有没有一起做网站的怎么推广自己的网站?
  • 仿门户网站咖啡seo是什么意思
  • 服务器搭建网站数据库网络平台推广方式
  • 本地网站建设电话东莞seo快速排名
  • 拓者吧室内设计吧官网关键词优化公司如何选择
  • 一个后台管理多个网站中国最新军事新闻
  • 莆田高端模板建站广州网络推广万企在线
  • 怎么做网站接口网站seo推广公司靠谱吗
  • 网站视觉设计规范站长工具seo综合查询烟雨楼
  • 河北沧州网站建设搜狗营销
  • 长乐区住房和城乡建设局网站搜索引擎营销推广方案
  • 公司商标设计logo图案seo网站技术培训
  • 外贸手机商城网站建设 深圳做百度线上推广
  • 8小8x在线免费观看2021罗湖区seo排名