设计模式
clearwwu
这个作者很懒,什么都没留下…
展开
-
设计模式c++
对比模板模式原创 2021-06-10 14:33:00 · 79 阅读 · 0 评论 -
设计模式c++
模板模式#include <iostream>#include <string>using namespace std;class people { void send() { cout << "我的名字是:"; cout << name(); cout << ", 年龄:" << age(); cout << ", 身高:" << height() << endl;原创 2021-06-10 10:58:54 · 63 阅读 · 0 评论 -
设计模式c++
外观模式//外观模式(Facade Pattern)隐藏系统的复杂性,并向客户端提供了一个客户端可以访问系统的接口。//将多个子系统封装起来,提供一个更简洁的接口供外部调用。#include <iostream>#include <string>using namespace std;class jecket {public: void wear() { cout << "穿上衣" << endl; } void takeoff(原创 2021-06-09 19:46:46 · 74 阅读 · 0 评论 -
设计模式c++
原型模式//原型模式(Prototype Pattern)是用于创建重复的对象,同时又能保证性能。//原型模式就是用来克隆对象的。#include <iostream>#include <string>using namespace std;class WorkExperience {public: string workDate; string company;public: void setWorkDate(string v) { workDate =原创 2021-06-09 14:45:36 · 66 阅读 · 0 评论 -
设计模式c++
静态代理模式#include <iostream>#include <string>using namespace std;class Subject {public: virtual void request() = 0; virtual void sendMsg() = 0;};class RealSubject : public Subject{ virtual void request() { cout << "real reques原创 2021-06-09 11:21:22 · 51 阅读 · 0 评论 -
设计模式c++
装饰模式//装饰模式:动态地给一个对象增加一些额外的职责#include <iostream>#include <string>using namespace std;class people {public: virtual int getValue() = 0;};class clothes :public people{public: virtual int getValue() { return 80; }};class Decorat原创 2021-06-09 10:23:43 · 62 阅读 · 0 评论 -
设计模式c++
策略模式#include <iostream>#include <string>using namespace std;class fruit {public: virtual string getCorlor() = 0;};class apple :public fruit {public: virtual string getCorlor() { return "红色"; }};class pear :public fruit {publ原创 2021-06-09 08:55:39 · 44 阅读 · 0 评论 -
c++ 设计模式
工厂模式1、简单工厂模式#pragma once#include <iostream>#include <string>using namespace std;class fruit {public: virtual string getCorlor() = 0;};class apple :public fruit {public: virtual string getCorlor() { return "红色"; }};class pea原创 2021-06-08 20:57:38 · 103 阅读 · 0 评论