C++
文章平均质量分 73
yjh201301
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
observer 简单实例
#include "Publicinc.hpp"class Observer{public: virtual ~Observer() { } virtual void Update(int n) = 0;};class Subject{ typedef std::vector ObserverList; type原创 2018-01-30 16:04:59 · 373 阅读 · 0 评论 -
可撤销的command pattern
#include "Publicinc.hpp"// Receiverclass Receiver{public: string GetContent() const { return m_content; } void SetContent(const string& content) { m_content = content; } void原创 2018-01-30 11:42:16 · 237 阅读 · 0 评论 -
visit pattern
#include "Publicinc.hpp"enum Gender{ Man = 0, Woman = 1,};class CStudent;class CTeacher;class CVisitor{public: virtual ~CVisitor() {} virtual void visi原创 2018-01-29 15:18:02 · 244 阅读 · 0 评论 -
function 的简单实现
template class Invoker_Base{public: virtual R operator()(Arg arg) = 0;};template class Function_Ptr_Invoker : public Invoker_Base{private: typedef R (*FUNC原创 2018-01-26 17:27:16 · 537 阅读 · 0 评论 -
command 模式示例
// receiverclass Tape_Recorder{public: void Play() { printf("since my baby left me: \n"); } void Stop() { printf("ok. taking a break.\n"); }原创 2018-01-26 12:19:34 · 246 阅读 · 0 评论 -
工厂模式和单例模式
#include #include using namespace std;class AbstractProductA{public: virtual ~AbstractProductA() {} virtual void Operation() = 0;};class AbstractProductB{public:原创 2018-01-09 14:32:11 · 237 阅读 · 0 评论 -
常用排序算法的效率
int Partition(int* data, int low, int high){ int key = data[low]; while (low while (low if (key --high; } else {原创 2018-01-25 11:24:30 · 297 阅读 · 0 评论 -
proxy 模式示例
#include "Publicinc.hpp"class Image{public: virtual ~Image() { } virtual void Display() = 0;};class RealImage : public Image{public: RealImage(const原创 2018-01-30 18:07:31 · 224 阅读 · 0 评论 -
继承,实现,关联,聚合,组合,依赖几种关系的介绍
继承: generalization继承是一种泛化的关系,是子类和父类之间的纵向关系;例如: 水果(一般化), 苹果,香蕉,橘子,榴莲(相对具体化);在逻辑上,子类是父类的一种,是“is-a”的关系;通常逻辑上具有上述关系("is-a")的类,就可以继承;子类继承父类,则子类拥有了父类的所有方法和属性;UML类图:实现:realization实现是类和接口之原创 2017-06-26 17:03:07 · 837 阅读 · 0 评论 -
设计模式之二: 策略模式
设计模式中的策略模式的学习原创 2017-07-01 16:40:42 · 223 阅读 · 0 评论
分享