设计模式:template method
来源:互联网 发布:电力cad软件 编辑:程序博客网 时间:2024/05/22 09:49
代码没有按照规范写~~
class Library{protected: virtual ~Library(){} bool step1(){ //稳定 //... } bool step2(){//稳定 //... } virtual bool step3() = 0;//变化 bool step4(){//稳定 //... } virtual bool step5() = 0;//变化 //“稳定”中有“变化 ” step1 step2 step 4是稳定的,step3、step5是变化的 //这个程序框架 也就是 run是“稳定”的 void run(){ step1(); if(step2()){ step3(); //支持变化 虚函数的多态调用 } for(int i=0;i<4;i++){ step4(); } step5();//支持变化 虚函数的多态调用 }};class UserApp : public Library{ bool step3(){ //具体实现 } bool step5(){ //具体实现 }};int main(){ Library* task = new UserApp(); task->run(); delete task;}
0 0
- 设计模式-template method
- Template Method-----设计模式
- Template Method设计模式
- 设计模式:template method
- C++设计模式-Template Method
- C++设计模式-Template Method
- C++设计模式-Template Method
- C++设计模式-Template Method
- C++设计模式-Template Method
- C++设计模式-Template Method
- [设计模式]1. Template Method
- Java设计模式-----Template Method模式
- C++设计模式13:Template Method 模式
- JAVA设计模式之Template Method模式
- C++设计模式:Template Method 模式
- Java设计模式-----Template Method模式
- 重学设计模式 - Template Method模式
- 设计模式----模板方法模式(Template Method)
- 4515: [Sdoi2016]游戏
- 20分钟复习《剑指Offer》
- activity切换的全局动画设置
- (三十四)、异常
- 前端学习总结(二十一)Vue.js——博采众长的后起之秀
- 设计模式:template method
- 关于集合运算
- 百度地图如何计算两点之间距离
- 深入理解Java内存模型(一)——基础
- ubuntu中使用usb转串口
- Xpoded模块开发教程
- Eclipse创建第二个包 却显示与SRC目录同级
- 程序退出,会直接回到桌面 而不会 退出到先前的activity界面
- 初识AngularJs(1)