![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
李御风
这个作者很懒,什么都没留下…
展开
-
C++ 单例(singleton)模式实现
1、饿汉式单例类#ifndef EAGER_SINGLETON_H #define EAGER_SINGLETON_H#include <iostream> #include <pthread.h> class EagerSingleton { public: ~EagerSingleton() { delete instance_;原创 2017-02-13 20:06:44 · 476 阅读 · 0 评论 -
C++简单工厂模式(Simple Factory Pattern)实现
#ifndef CHART_H #define CHART_H#include <iostream> #include <string> class Chart { public: virtual void display() = 0; };class HistogramChart : public Chart { public: Hist原创 2017-02-14 21:56:16 · 227 阅读 · 0 评论 -
C++工厂方法模式(Factory Method Pattern)
#ifndef LOGGER_H #define LOGGER_H#include <iostream> #include <string> class Logger { public: virtual void writeLog() = 0; };class DatabaseLogger : public Logger { public: void原创 2017-02-14 22:27:43 · 538 阅读 · 0 评论 -
C++抽象工厂模式(abstract factory patterns)实现
#ifndef SKIN_H #define SKIN_H#include <iostream> //Button class Button { public: virtual void display() = 0;};class SpringButton : public Button { public: void display() {原创 2017-02-15 19:23:27 · 418 阅读 · 0 评论