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

张家口网站设计楼市最新消息2022年房价走势

张家口网站设计,楼市最新消息2022年房价走势,wordpress移动端菜单,从零学做网站装饰模式#xff0c;动态地给一个对象添加一些额外的职责。就增加功能来说#xff0c;Decorator模式相比生成子类更为灵活。 13.1.解释 main()#xff0c;老爸 ISchoolReport#xff0c;成绩单接口 CFourthGradeSchoolReport#xff0c;四年级成绩单 ReportDecorator…装饰模式动态地给一个对象添加一些额外的职责。就增加功能来说Decorator模式相比生成子类更为灵活。 13.1.解释 main()老爸 ISchoolReport成绩单接口 CFourthGradeSchoolReport四年级成绩单 ReportDecorator成绩单装饰器基类 HighScoreDecorator最高分装饰器 SortDecorator班级排名装饰器 说明对“四年级成绩单”进行装饰ReportDecorator必然有一个private变量指向ISchoolReport。 注意 看代码 // Decorator.cpp//主程序#include stdafx.h#include ISchoolReport.h#include FouthGradeSchoolReport.h#include SugarFouthGradeSchoolReport.h#include HighScoreDecorator.h#include SortDecorator.h#include iostreamusing std::cout;using std::endl;void DoIt(){    ISchoolReport *psr new CSugarFouthGradeSchoolReport();    psr-Report();//看成绩单    psr-Sign(老三);//很开心就签字了    delete psr;}void DoNew(){    cout ----------分部分进行装饰---------- endl;    ISchoolReport *psr new CFouthGradeSchoolReport();//原装成绩单    //    ISchoolReport *pssr new CSortDecorator(psr);//又加了成绩排名的说明    ISchoolReport *phsr new CHighScoreDecorator(pssr);//加了最高分说明的成绩单    phsr-Report();//看成绩单    phsr-Sign(老三);//很开心就签字了        //先装饰哪个不重要顺序已经在装饰内部确定好但一定要调用最后一个装饰器的接口。    //ISchoolReport *phsr new CHighScoreDecorator(psr);//加了最高分说明的成绩单    //ISchoolReport *pssr new CSortDecorator(phsr);//又加了成绩排名的说明    //pssr-Report();//看成绩单    //pssr-Sign(老三);//很开心就签字了    delete pssr;    delete phsr;    delete psr;}int _tmain(int argc, _TCHAR* argv[]){    //在装饰之前可以用继承的办法来进行简单的修饰    DoIt();    //但如果需要修饰的项目太多呢或者装饰的项目不是固定的继承显然会变得更复杂    DoNew();    _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);    _CrtDumpMemoryLeaks();    return 0;} //ISchoolReport.h #pragma once#include iostreamusing std::string;class ISchoolReport{public:    ISchoolReport(void)    {    }    virtual ~ISchoolReport(void)    {    }    virtual void Report() 0;    virtual void Sign(string name) 0;}; //FouthGradeSchoolReport.h #pragma once#include ischoolreport.hclass CFouthGradeSchoolReport :    public ISchoolReport{public:    CFouthGradeSchoolReport(void);    ~CFouthGradeSchoolReport(void);    void Report();    void Sign(string name);}; //FouthGradeSchoolReport.cpp #include StdAfx.h#include FouthGradeSchoolReport.h#include iostreamusing std::cout;using std::endl;using std::string;CFouthGradeSchoolReport::CFouthGradeSchoolReport(void){}CFouthGradeSchoolReport::~CFouthGradeSchoolReport(void){}void CFouthGradeSchoolReport::Report(){    cout 尊敬的XXX家长 endl;    cout ...... endl;    cout 语文62  数学65  体育98  自然63 endl;    cout ...... endl;    cout                 家长签名 endl;}void CFouthGradeSchoolReport::Sign(string name){    cout 家长签名为 name.c_str() endl;} //ReportDecorator.h #pragma once#include ischoolreport.hclass CReportDecorator :    public ISchoolReport{public:    CReportDecorator(ISchoolReport *psr);    virtual ~CReportDecorator(void);    void Report();    void Sign(string name);private:    ISchoolReport *m_pSchoolReport;}; //ReportDecorator.cpp #include StdAfx.h#include ReportDecorator.h#include iostreamusing std::string;CReportDecorator::CReportDecorator(ISchoolReport *psr){    this-m_pSchoolReport psr;}CReportDecorator::~CReportDecorator(void){}void CReportDecorator::Report(){    this-m_pSchoolReport-Report();}void CReportDecorator::Sign( string name ){    this-m_pSchoolReport-Sign(name);} //HighScoreDecorator.h #pragma once#include reportdecorator.h#include ISchoolReport.hclass CHighScoreDecorator :    public CReportDecorator{public:    CHighScoreDecorator(ISchoolReport *psr);    ~CHighScoreDecorator(void);    void Report();private:    void ReportHighScore();}; //HighScoreDecorator.cpp #include StdAfx.h#include HighScoreDecorator.h#include iostreamusing std::cout;using std::endl;CHighScoreDecorator::CHighScoreDecorator( ISchoolReport *psr ) : CReportDecorator(psr){}CHighScoreDecorator::~CHighScoreDecorator(void){}void CHighScoreDecorator::Report(){    this-ReportHighScore();    this-CReportDecorator::Report();}void CHighScoreDecorator::ReportHighScore(){    cout 这次考试语文最高是75 数学是78 自然是80 endl;} //SortDecorator.h #pragma once#include reportdecorator.h#include ISchoolReport.hclass CSortDecorator :    public CReportDecorator{public:    CSortDecorator(ISchoolReport *psr);    ~CSortDecorator(void);    void Report();private:    void ReportSort();};//SortDecorator.cpp #include StdAfx.h#include SortDecorator.h#include iostreamusing std::cout;using std::endl;CSortDecorator::CSortDecorator( ISchoolReport *psr ) : CReportDecorator(psr){}CSortDecorator::~CSortDecorator(void){}void CSortDecorator::ReportSort(){    cout 我是排名第38名... endl;}void CSortDecorator::Report(){    this-CReportDecorator::Report();    this-ReportSort();} 这也是一个比较简单的模式属于行为型模式。 转载于:https://www.cnblogs.com/wanggary/archive/2011/04/18/2020254.html
http://www.sadfv.cn/news/266813/

相关文章:

  • 网站建设与管理视频宁波市公共资源交易中心官网
  • 温州网站推广有哪些方法站内推广途径
  • 网站在线制作生成电子商务网站建设与管理相关论文
  • 网站是什么?做行业网站广告
  • 商城网站的设计风格wordpress接入paypal
  • 电子商务网站管理系统南京网站设计建设推荐
  • 南阳建设重要区域中心城市网站网站制作做站长挣钱
  • php小网站wordpress文章id排列
  • 没有域名可以建网站吗rails 网站开发
  • 网站建设改版升级制作网页怎样添加背景音乐
  • 如何留住网站用户哈尔滨模板建站定制网站
  • 学网站建设可以从事什么工作信息网官网
  • 深圳海洋网络做网站成立公司需要几个人
  • 商业网站改版需要多久中国外贸导航网
  • 诸暨网站开发域名注册服务
  • 汉网网站建设做托福的网站
  • 如何更换网站空间千万别去代理记账公司
  • 北京做网站的公司东道wordpress中文语言
  • 做装修网站云南住房和城乡建设厅网站首页
  • 门户网站营销可以看违禁网页的浏览器
  • drupal和wordpress怎么做网站优化排名
  • html模板网站推荐工厂管理培训课程
  • 网站系统怎么做营销网站制作都选ls15227
  • 非官方网站建设给被k的网站做友链
  • 怎么能将网站做的不简单牡丹区住房和城乡建设局网站
  • 如何选择深圳网站建设3d地图网站模板html
  • 国家建设工程造价数据监测平台在哪个网站网络营销论文总结
  • 公司核名在哪个官方网站如何优化网站信息架构
  • 有口碑的盐城网站建设网页设计论文题目大全
  • 网站没被收录做网站运营经理的要求