标签:c++ 设计模式
#include "stdafx.h" #include <iostream> class Adaptee { public: void Request() { std::cout << "实际要使用的类方法!" << std::endl; } }; class Target { public: virtual ~Target(){} virtual void Operator() = 0; }; class Adapter :public Target { private: Adaptee* m_Adaptee = new Adaptee(); public: virtual void Operator() { m_Adaptee->Request(); } };
// AdapterPattern.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Adapter.h" int _tmain(int argc, _TCHAR* argv[]) { Target* target = new Adapter(); target->Operator(); getchar(); return 0; }
标签:c++ 设计模式
原文地址:http://blog.csdn.net/wwwdongzi/article/details/26941917