#include <iostream>
using namespace std;
enum CoreType
{
CORE_A,
CORE_B
};
struct ISingleCore
{
public:
virtual ~ISingleCore() { }
virtual void Produce() = 0;
};
class CSingleCoreA : public ISingleCore
{
public:
virtual ~CSingleCoreA() { }
virtual void Produce() { cout<<"Single Core A"<<endl; }
};
class CSingleCoreB : public ISingleCore
{
public:
virtual ~CSingleCoreB() { }
virtual void Produce() { cout<<"Single Core B"<<endl; }
};
class CFactory
{
public:
ISingleCore* CreateSingleCore(CoreType type)
{
if(CORE_A == type)
return new CSingleCoreA();
else if(CORE_B == type)
return new CSingleCoreB();
}
};
void main()
{
CFactory factory;
ISingleCore *pSingleCoreA = factory.CreateSingleCore(CORE_A);
pSingleCoreA->Produce();
delete pSingleCoreA;
ISingleCore *pSingleCoreB = factory.CreateSingleCore(CORE_B);
pSingleCoreB->Produce();
delete pSingleCoreB;
}