2012年11月6日
摘要: /*****************************************CSlot.h****************************************/#include using namespace std;//两相的插头基类class CTwoSlotsPlug{public:virtual void plugIn2Slots() = 0;};//一个实插头类:红色的二相插头class CRed2SlotsPlug : public CTwoSlotsPlug{public:void plugIn2Slots(){coutplugIn2Slots();}};// 阅读全文
posted @ 2012-11-06 11:19 bitbit 阅读(302) 评论(0) 推荐(0) 编辑
摘要: /*****************************************baseobject.h******************************************//*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@我这里写一个非常实用的例子,是我的一个项目的对象基类构造函数的超级简化版本.这个对象的基类构造函数会调用一个initailize函数来初始化一个对象.该initailize中有很多步骤,每一个都由其子类来决定如何初始化@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 阅读全文
posted @ 2012-11-06 11:06 bitbit 阅读(248) 评论(0) 推荐(0) 编辑
摘要: /*************************************CSingleton.h**************************************/#pragma once#include #include using namespace std;class CSingleton{private:CSingleton(){coutusing namespace std;class testSingleton{public:testSingleton(){CSingleton::getSingleton();cout#include "CSingleton 阅读全文
posted @ 2012-11-06 11:02 bitbit 阅读(178) 评论(0) 推荐(0) 编辑
摘要: /***********************************baseobject.h***********************************/#pragma once#include #include #include #include "CIterator.h"#define MAX_ARRAY_SIZE 100using namespace std;//前置定义class CIteratorInterface;class CElectricIterator;//////////////////////////////////////////// 阅读全文
posted @ 2012-11-06 10:58 bitbit 阅读(301) 评论(0) 推荐(0) 编辑
摘要: /************************************************************CStatePattern.h************************************************************/#pragma once#include using namespace std;class CState;class CSoldState;class CSoldOutState;class CNoQuarterState;class CHasQuarterState;//游戏机class CGumballMachine{ 阅读全文
posted @ 2012-11-06 10:52 bitbit 阅读(244) 评论(0) 推荐(0) 编辑
摘要: /****************************************************************CCharactor.h****************************************************************/#pragma once#include "CWeapon.h"////////////////////////////////////////////////////////这是人物类的纯虚基类class CCharactor{protected://多用组合,少用继承。 //这里使用策略模式 阅读全文
posted @ 2012-11-06 10:43 bitbit 阅读(245) 评论(0) 推荐(0) 编辑
摘要: /**********************************************************************CCommand.h**********************************************************************/#pragma once#include "Objects.h"#include using namespace std;//命令对象类的基类class CCommand{public:virtual void execute() = 0;};//空命令对象,什么都不做。只实 阅读全文
posted @ 2012-11-06 10:40 bitbit 阅读(273) 评论(0) 推荐(0) 编辑
摘要: /*****************************************************component.h****************************************************/#pragma once#include #include using namespace std;///////////////////////////////组件类的基类//1. 所有组件全都派生自这个组件//2. 装饰都类的纯虚基类也派生自这个组件class CBaverage{protected:string m_description;float m_ 阅读全文
posted @ 2012-11-06 10:36 bitbit 阅读(288) 评论(0) 推荐(0) 编辑
摘要: /******************************************************baseobject.h******************************************************/#pragma once#include #include #include #include "CIterator.h"#define MAX_ARRAY_SIZE 100using namespace std;//前置定义class CIteratorInterface;class CElectricIterator;////// 阅读全文
posted @ 2012-11-06 10:30 bitbit 阅读(458) 评论(0) 推荐(0) 编辑
摘要: 有些时候,我们需要把一大堆复杂的接口简化后呈现给用户。/****************************************************CEquipments.h****************************************************//*电视、空调、电脑、DVD机、音箱等设备*/#pragma once#include using namespace std;class CTV{public:void start(){coutstart(); m_Aircondition->start(); m_pc->start(); m 阅读全文
posted @ 2012-11-06 10:23 bitbit 阅读(317) 评论(0) 推荐(0) 编辑
摘要: /**********************************************************CPaper.h**********************************************************/#pragma once#include #include using namespace std;class CPaper{public:string context;public:CPaper(){}CPaper(const string& _cont){context = _cont;}CPaper(const CPaper& 阅读全文
posted @ 2012-11-06 10:14 bitbit 阅读(392) 评论(0) 推荐(0) 编辑
摘要: 1.工厂方法模式:/************************************* CPizza.h*************************************/#pragma once#include using namespace std;class CPizza {public:virtual string getDescription() = 0;};class CNYCheesePizza : public CPizza{public:string getDescription(){return string("a new york cheese 阅读全文
posted @ 2012-11-06 10:07 bitbit 阅读(960) 评论(0) 推荐(0) 编辑