添加设计模式及例子,包括:单例、抽象工厂、适配器、桥接、观察者模式

This commit is contained in:
huihut
2018-07-22 14:50:54 +08:00
parent 92bc715c1f
commit b69685a5a7
31 changed files with 839 additions and 31 deletions

View File

@@ -0,0 +1,30 @@
//
// Created by xiemenghui on 2018/7/21.
//
#include "BridgeMain.h"
void BridgeMain()
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD><C6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>
IElectricalEquipment * light = new Light();
IElectricalEquipment * fan = new Fan();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ء<EFBFBD><D8A1><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>أ<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>غ͵<D8BA><CDB5>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>غͷ<D8BA><CDB7>ȹ<EFBFBD><C8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ISwitch * pullChain = new PullChainSwitch(light);
ISwitch * twoPosition = new TwoPositionSwitch(fan);
// <20><><EFBFBD>ơ<EFBFBD><C6A1>ص<EFBFBD>
pullChain->On();
pullChain->Off();
// <20>򿪷<EFBFBD><F2BFAAB7>ȡ<EFBFBD><C8A1>رշ<D8B1><D5B7><EFBFBD>
twoPosition->On();
twoPosition->Off();
SAFE_DELETE(twoPosition);
SAFE_DELETE(pullChain);
SAFE_DELETE(fan);
SAFE_DELETE(light);
}