#include <iostream>
#include <vector>
using namespace std;
//
struct ILight
{
public:
virtual ~ILight() { }
virtual void Switch() = 0;
};
class CLightOn : public ILight
{
public:
virtual ~CLightOn() { }
virtual void Switch() { cout<<"on to off"<<endl; }
};
class CLightOff : public ILight
{
public:
virtual ~CLightOff() { }
virtual void Switch() { cout<<"off to on"<<endl; }
};
class CContext
{
public:
CContext() { }
void Switch(ILight *pLight) { pLight->Switch(); }
};
//
void main()
{
CContext context;
CLightOn lightOn;
context.Switch(&lightOn);
}