// ConsoleApplication1.cpp : Defines the entry point for the console application.
//Target生成对象是合理的,so不用纯虚函数
#include "stdafx.h"
#include <iostream>
//#include "Factory.h"
using namespace std;
class Target
{
public:
virtual void Request()
{
cout<<"this is the target's request"<<endl;
}
};
class Adaptee
{
public:
void SpecialRequest()
{
cout<<"this is the specialRequest"<<endl;
}
};
class Adapter:public Target, public Adaptee
{
public:
void Request()
{
SpecialRequest();
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Target* pTarget = new Adapter;
pTarget->Request();
delete pTarget;
getchar();
return 0;
}
//Target生成对象是合理的,so不用纯虚函数
#include "stdafx.h"
#include <iostream>
//#include "Factory.h"
using namespace std;
class Target
{
public:
virtual void Request()
{
cout<<"this is the target's request"<<endl;
}
};
class Adaptee
{
public:
void SpecialRequest()
{
cout<<"this is the specialRequest"<<endl;
}
};
class Adapter:public Target, public Adaptee
{
public:
void Request()
{
SpecialRequest();
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Target* pTarget = new Adapter;
pTarget->Request();
delete pTarget;
getchar();
return 0;
}