导航
您当前的位置:首页 > 计算机 > 软件水平
问题:

[问答题] 现欲开发一个软件系统,要求能够同时支持多种不同的数据库,为此采用抽象工厂模式设计该系统。以SQL Server和Access两种数据库以及系统中的数据库表Department为例,其类图如图5-1所示。中级软件设计师,历年真题,2012年下半年(下午)《软件设计师》真题图5-1类图【C++代码】#include<iostream>using namespace std;class Department{/*代码省略*/};class IDepartment{public:(1)=0;(2)=0;};class SqlserverDepartment:(3){public:void Insert(Department*department){cout<<"Insert a record into Department in SQL Server!\n";∥其余代码省略}Department GetDepartment(int id){/*代码省略*/}};class AccessDepartment:(4){public:void Insert(Department*department){cout<<"Insert a record into Department in ACCESS!\n";∥其余代码省略}Department GetDepartment(int id){/*代码省略*/}};(5){public:(6)=0;};class SqlServerFactory:public IFactory{public:IDepartment*CreateDepartment(  ){return new SqlserverDepartment(  );}∥其余代码省略};class AccessFactory:public IFactory{public:IDepartment*CreateDepartment(  ){return new AccessDepartment(  );}∥其余代码省略};
答案解析:

相关问题
关于我们 | 用户指南 | 版权声明 | 给我留言 | 联系我们 | 积分商城 | 答案求助 | 网站地图
Copyright © 2024 www.daanwo.com All Rights Reserved