C++设计模式之桥接模式
来源:互联网 发布:杜蕾斯大胆爱厚度 知乎 编辑:程序博客网 时间:2024/05/22 14:36
#include <iostream>#include <string>#include <stdlib.h>using namespace std;class OS{private: string name;public: OS(string n) :name(n){}; void set_name(string n) { this->name = n; } string get_name() { return this->name; }};class XP :public OS{public: XP(string n = "XP") :OS(n){};};class Win7 :public OS{public: Win7(string n = "Win7") :OS(n){};};class Linux :public OS{public: Linux(string n = "Linux") :OS(n){};};class Computer{private: string brand; OS os;public: Computer(OS xt, string b) :brand(b), os(xt){}; void set_os(OS os) { this->os = os; } OS get_os() { return this->os; } void init() { cout << brand << "电脑正在运行" << os.get_name() << endl; }};class Dell:public Computer{public: Dell(OS os, string b = "Dell") :Computer(os, b){};};class Lenovo :public Computer{public: Lenovo(OS os, string b = "Lenovo") :Computer(os, b){};};int main(){ XP xp; Win7 win7; Linux linux; Dell dell(xp); Lenovo lenovo(win7); dell.init(); lenovo.init(); dell.set_os(linux); dell.init(); system("pause");}
阅读全文
0 0
- C#--设计模式之桥接模式
- 设计模式_桥接模式(C++)
- 设计模式之桥接模式
- C# 设计模式 之 桥接模式
- c#设计模式之[桥接模式]
- 设计模式之桥接模式
- 设计模式之-Bridge-- 桥接模式
- 设计模式之桥接模式
- 设计模式之桥接模式
- 设计模式之Bridge(桥接模式)
- 设计模式之桥接模式
- 设计模式之Bridge(桥接模式)
- 设计模式之桥接模式BridgePattern
- C# 设计模式之桥接模式
- 设计模式之桥接模式
- 设计模式之桥接模式
- Java 设计模式 之 桥接模式
- Java 设计模式 之 桥接模式
- 后缀数组
- Ubuntu16.04中cuDNN安装教程
- Spring MVC 配置总结
- 【数据结构】单调栈
- android ANR小结
- C++设计模式之桥接模式
- Android学习路之GridLayout
- # 基于Kotlin的Android开发(1):安装Kotlin插件并编译项目
- angular1基础
- 自定义指令集的CPU设计
- 贪心算法实例(一):多任务分配问题
- HTTP详解--Http协议(三)
- 如何实现自己没实现过的需求之文本动画
- 5.比特币中热存储,冷存储和分层钱包问题