⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 democratfactory.cpp

📁 设计模式实例: 工厂方法(Factory)源代码)
💻 CPP
字号:
// DemocratFactory.cpp: implementation of the DemocratFactory class.
//
//////////////////////////////////////////////////////////////////////

#include "DemocratFactory.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

DemocratFactory::DemocratFactory()
{

}

DemocratFactory::~DemocratFactory()
{

}

Officer*  DemocratFactory::CreateOfficer(OfficialType type)
{
	if(m_Officer!=NULL)
		delete m_Officer;
	switch(type)
	{
		case PresidentType:
			m_Officer=new President("Democrat");
			break;
		case AttorneyGeneralType:
			m_Officer=new AttorneyGeneral("Democrat");
			break;
		case MinorityPartyCongressPersonType:
		    m_Officer=new MinorityPartyCongressPerson("Democrat");
			break;
		default:
			break;
	}
	return m_Officer;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -