// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#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:
Adapter():m_pAdaptee(new Adaptee) {}
~Adapter()
{
if(m_pAdaptee != NULL)
{
delete m_pAdaptee;
m_pAdaptee = 0;
}
}
void Request()
{
m_pAdaptee->SpecialRequest();
}
protected:
Adaptee* m_pAdaptee;
};
int _tmain(int argc, _TCHAR* argv[])
{
Target* pTarget = new Adapter;
pTarget->Request();
delete pTarget;
getchar();
return 0;
}
//
#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:
Adapter():m_pAdaptee(new Adaptee) {}
~Adapter()
{
if(m_pAdaptee != NULL)
{
delete m_pAdaptee;
m_pAdaptee = 0;
}
}
void Request()
{
m_pAdaptee->SpecialRequest();
}
protected:
Adaptee* m_pAdaptee;
};
int _tmain(int argc, _TCHAR* argv[])
{
Target* pTarget = new Adapter;
pTarget->Request();
delete pTarget;
getchar();
return 0;
}