下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
【移动应用开发技术】桥接模式
在提出桥梁模式的时候指出,桥梁模式的用意是"将抽象化(Abstraction)与实现化(Implementation)脱耦,使得二者可以独立地变化"。这句话有三个关键词,也就是抽象化、实现化和脱耦。抽象化实现化脱耦将两个角色之间的继承关系改为聚合关系,就是将它们之间的强关联改换成为弱关联。因此,桥梁模式中的所谓脱耦,就是指在一个软件系统的抽象化和实现化之间使用组合/聚合关系而不是继承关系,从而使两者可以相对独立地变化。这就是桥梁模式的用意。在使用VIM编写makefile时,有时TAP键会是八个空格,使用setlist命令可以查看所有的TAB键是否正确。makefile文件aLL:Brige
CC=g++
INCLUDE=.
CFLAGS=-g-Wall
Brige:main.oCDrawLine.oCDrawSquare.oCSqureRefined.oCCircleRefined.o
$(CC)-oBrigemain.oCDrawLine.oCDrawSquare.oCSqureRefined.oCCircleRefined.o
CDrawSquare.o:CDrawSquare.cppCDrawSquare.hCImplement.cpp
$(CC)-I$(INCLUDE)$(CFLAGS)-cCDrawSquare.cpp
CDrawLine.o:CDrawLine.cppCDrawLine.h
$(CC)-I$(INCLUDE)$(CFLAGS)-cCDrawLine.cpp
CSqureRefined.o:CSqureRefined.cppCSqureRefined.h
$(CC)-I$(INCLUDE)$(CFLAGS)-cCSqureRefined.cpp
CCircleRefined.o:CCircleRefined.cppCCircleRefined.h
$(CC)-I$(INCLUDE)$(CFLAGS)-cCCircleRefined.cpp
main.o:main.cpp
$(CC)-I$(INCLUDE)$(CFLAGS)-cmain.cpp
clean:
rm*.o
rmBrigeCAbstraction.h#ifndefCAbstractiongH
#defineCAbstractiongH
#include<iostream>
#include"CImplement.h"
usingnamespacestd;
classCAbstractiong
{
public:
virtual~CAbstractiong(){};
virtualvoidOperation()=0;
voidSetImplement(CImplement*tImplement){m_CImplement=tImplement;};
protected:
CAbstractiong(){};
CImplement*m_CImplement;
};
#endifCCircleRefined#ifndefCCircleRefinedH
#defineCCircleRefinedH
#include"CAbstraction.h"
classCCircleRefined:publicCAbstractiong
{
public:
CCircleRefined(){};
~CCircleRefined(){};
voidOperation();
};
#endif
#include"CCircleRefined.h"
voidCCircleRefined::Operation()
{
cout<<"对圆形进行了"<<m_CImplement->Operation()<<endl;
}CSqureRefined#ifndefCSqureRefinedH
#defineCSqureRefinedH
#include"CAbstraction.h"
classCSqureRefined:publicCAbstractiong
{
public:
CSqureRefined(){};
~CSqureRefined(){};
voidOperation();
};
#endif
#include"CSqureRefined.h"
voidCSqureRefined::Operation()
{
cout<<"对正方形进行了"<<m_CImplement->Operation()<<endl;
}CAbstractiong#ifndefCAbstractiongH
#defineCAbstractiongH
#include<iostream>
#include"CImplement.h"
usingnamespacestd;
classCAbstractiong
{
public:
virtual~CAbstractiong(){};
virtualvoidOperation()=0;
voidSetImplement(CImplement*tImplement){m_CImplement=tImplement;};
protected:
CAbstractiong(){};
CImplement*m_CImplement;
};
#endifCDrawSquare#ifndefCDrawSquareH
#defineCDrawSquareH
#include<iostream>
#include"CImplement.h"
classCDrawSquare:publicCImplement
{
public:
CDrawSquare(){};
~CDrawSquare(){};
stringOperation();
};
#endif
#include"CDrawSquare.h"
#include<iostream>
usingnamespacestd;
stringCDrawSquare::Operation()
{
stringsTemp="进行了画方格操作";
returnsTemp;
}CDrawLine#ifndefCDrawLineH
#defineCDrawLineH
#include<iostream>
#include<string>
#include"CImplement.h"
classCDrawLine:publicCImplement
{
public:
CDrawLine(){};
~CDrawLine(){};
stringOperation();
};
#endif
#include"CDrawLine.h"
#include<iostream>
usingnamespacestd;
stringCDrawLine::Operation()
{
stringsTemp="进行了画线操作";
returnsTemp;
}main.cpp#include"CDrawLine.h"
#include"CDrawSquare.h"
#include"CSqureRefined.h"
#include"CCircleRefined.h"
intmain()
{
CDrawLine*pCDrawLine=newCDrawLine();
CCircleRefined*pCCircleRefined=newCCircleRefined();
pCCircleRefined->SetImplement(pCDra
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年农村租田合同范本
- 2024年外贸销售合同模板
- 中介办公楼出租合同
- 中国广告网区域代理的合同模板
- 阀门标识和型号全套
- 合资建厂协议书
- 2024年大型重工装备铸件项目建议书
- 2024年上海市徐汇区中考三模数学试题
- 2024年矿用防爆电器合作协议书
- 2024年二位五通电磁阀合作协议书
- 常州市十大产业链Word版
- 2022年高考生物真题试卷(江苏卷)带答案解析
- 课件104条严重违章释义
- 微生物作业指导书
- 软件运维服务方案
- 幼儿园绘本:《倔强的小红军》 红色故事
- 2022年医学专题-狂犬病
- 路基路面课程设计计算说明书沥青路面利用诺谟图计算
- 初中学业水平考试-体育与健康综合知识测试题库(480题)
- 北师大数学三年级下册《小小设计师》优质课件
- 计算机软硬件采购制度建设
评论
0/150
提交评论