首页 > 题库 > 职业考证 > 软考 > 软件设计师 > 案例题

阅读下列说明和C++代码,将应填入(n)处的字句写在对应栏内。
【说明】
现欲开发一个软件系统,要求能够同时支持多种不同的数据库,为此采用抽象工厂模式设计该系统。以SQL Server和Access两种数据库以及系统中的数据库表Department为例,其类图如图5-1所示。

图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();}
    ∥其余代码省略
};

参考答案: 查看答案 查看解析 下载APP畅快刷题

相关知识点试题

相关试卷