现在位置: 首页 > 设计模式
#include <iostream> #include <list> using namespace std; // struct IResume { public:     virtual ~IResume() { }     virtual void SetPersonalInfo() = 0;     virtual void SetEducationInfo() = 0;     virtual void SetWorkInfo() = 0;     void FillResume()     {   ...
阅读全文
#include <iostream> #include <list> using namespace std; // struct IObserver { public:     virtual ~IObserver() { }     virtual void Update() = 0; }; class CObserver : public IObserver { public:     CObserver(string name) : m_name(name) { }     virtual ~CObserver() { }     virtual...
阅读全文
#include <iostream> using namespace std; // struct ITravelWay { public:     virtual ~ITravelWay() { }     virtual void Travel() = 0; }; class CTrainWay : public ITravelWay { public:     virtual ~CTrainWay() { }     virtual void Travel() { cout<<"Travel by train."<<endl; } }; class CA...
阅读全文
代理模式,对象适配器模式的区别: 适配器模式:适配者与被适配者接口不同,为了是用户使用同一的接口。    代理模式:代理者与被代理者接口相同,只是客户不能访问到被代理者。 #include <iostream> using namespace std; // struct IImage { public:     IImage(string name) : m_name(name) { }     virtual ~IImage() { }     virtual void ...
阅读全文
#include <iostream> using namespace std; // class CDeque { public:     void push_front() { cout<<"CDeque push_front."<<endl; }     void push_back()  { cout<<"CDeque push_back."<<endl; }     void pop_front()  { cout<<"CDeque pop_front."<<endl; } ...
阅读全文
#include <iostream> using namespace std; // class CDeque { public:     void push_front() { cout<<"CDeque push_front"<<endl; }     void push_back()  { cout<<"CDeque push_back"<<endl; }     void pop_front()  { cout<<"CDeque pop_front"<<endl; }  ...
阅读全文
#include <iostream> #include <string> using namespace std; // class CScanner { public:     void Scan() { cout<<"词法分析"<<endl; } }; class CParse { public:     void Parse() { cout<<"语法分析"<<endl; } }; class CGenMidCode { public:     void GenMidCode() { c...
阅读全文
#include <iostream> #include <string> using namespace std; // struct IPhone { public:     IPhone() { }     virtual ~IPhone() { }     virtual void ShowDecorate() = 0; }; class CApplePhone : public IPhone { public:     CApplePhone(string name) : m_name(name) { }     virtual ~CApp...
阅读全文
#include <iostream> #include <string> #include <vector> using namespace std; // struct ICompany { public:     ICompany(string name) : m_name(name) { }     virtual ~ICompany() { }     virtual void Add(ICompany *pCompany) = 0;     virtual void Show(int nDepth) = 0; protected:    ...
阅读全文
#include <iostream> using namespace std; // struct IOS { public:     virtual ~IOS() { }     virtual void InstallOS_Imp() = 0; }; class CWindowsOS : public IOS { public:     virtual ~CWindowsOS() { }     virtual void InstallOS_Imp() { cout<<"Windows."<<endl; } }; class CLinuxOS : publ...
阅读全文