2012年8月20日
摘要: #include <iostream>using namespace std;class Singleton {private: Singleton() { } ~Singleton() { } static Singleton* pSingleton;public: static Singleton* GetInstance() { if (pSingleton == NULL) { pSingleton = new Singleton(); } return pSingleton; }};... 阅读全文
posted @ 2012-08-20 19:09 晴朗蝈蝈 阅读(70) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;/* 适配器模式:在复用已有代码出现接口不匹配的时候使用 适配器实际上是一个继承自目标接口的类,包含有一个以 往的接口,通过在重载方法中调用原来接口,来实现适配*///目标接口,适配器类继承此接口class Target {public: virtual void Request() { cout<<"普通请求"<<endl; }};//原有接口,需要包装在适配器类的接口中class Adaptee {public: void SpecificRequest() 阅读全文
posted @ 2012-08-20 16:32 晴朗蝈蝈 阅读(112) 评论(0) 推荐(0) 编辑