问题 问答题

试题五

阅读下列说明和C++代码,将应填入(n)处的字句写在答题纸的对应栏内。

【说明】 某公司的组织结构图如图5-1所示,现采用组合(Composition)设计模式来构造该公司的组织结构,得到如图5-2所示的类图。

其中Company为抽象类,定义了在组织结构图上添加(Add)和删除(Delete)分公司/办事处或者部门的方法接口。类ConcreteCompany表示具体的分公司或者办事处,分公司或办事处下可以设置不同的部门。类HRDepartment和FinanceDepartment分别表示人力资源部和财务部。 【C++代码】 #include #include #include using namespace std; class Company{//抽象类 protected: string name; public: Company(string name){(1)=name;} (2);//增加子公司、办事处或部门 (3);//删除子公司、办事处或部门 }; class ConcreteCompany:public Company{ private: list< (4)>children;//存储子公司、办事处或部门 public: ConcreteCompany(string name):Company(name){} void Add(Company* c){(5) .push back(c);} void Delete(Company* c){(6).remove(c);} }; class HRDepartment:public Company{ public: HRDepartment(string name):Company(name){}//其它代码省略 }; class FinanceDepartment:public Company{ public: FinanceDepartment(string name):Company(name){}//其它代码省略 }; void main(){ ConcreteCompany *root=new ComcreteCompany(“北京总公司”,); root->Add(new HRDepartment(“总公司人力资源部”)): root->Add(new FinanceDepartment(“总公司财务部”)); ConcreteCompany *comp=new ConcreteCompany(“上海分公司”); comp->Add(new HRDepartment(“上海分公司人力资源部”)); comp->Add(new FinanceDepartment(“上海分公司财务部”)); (7); ConcreteCompany *compl=new ConcreteCompany(“南京办事处”,): comp l->Add(new HRDepartment(“南京办事处人力资源部”)); comp l->Add(new FinanceDepartment(“南京办事处财务部”)): (8);//其它代码省略 }

(4)处填()。

答案

参考答案:

Company*

选择题
单项选择题

Personality is to a large extent inherent. A-type parents usually (1) A-type offspring. But the environment must also have a profound effect (2) if competition is important to the parents, it is (3) to become a major factor in the lives of their children.

One place where children (4) A characteristics is school, which is, (5) its very nature, a highly competitive institution. Too many schools (6) the "win at all costs" moral standard and measure their success by sporting achievements. The current (7) for making children compete against their classmates or against the (8) produces a two-layer system, in which competitive A types seem in some way better than their B type fellows. Being too (9) to win can have dangerous consequences: remember that Pheidippides, the first marathon runner, (10) dead seconds after saying. "Rejoice, we conquer!"

(11) the worst form of competition in schools is the disproportionate emphasis on examinations. There is, for example, a (12) school that allows pupils to concentrate on those things they do well. The (13) of competition by examination are somewhat questionable, but competition in the certain (14) of failure is positively harmful.

(15) , it is neither practical nor desirable that all A youngsters change into B’s. The world needs types, and schools have an important duty to try to (16) a child’s personality to his possible future employment. It is top management.

If the preoccupation of schools with academic work was (17) , more time might be spent teaching children surer values. Perhaps selection (18) the caring professions, especially medicine, could be made less by good grades in chemistry and more by such (19) as sensitivity and sympathy. It is surely a mistake to choose our doctors exclusively from A type stock. B’s are important and should be (20) .

9()

A.liable

B.ready

C.keen

D.fond