问题 填空题

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

[说明]

在一公文处理系统中,开发者定义了一个公文类OfficeDoc,其中定义了公文具有的属性和处理公文的相应方法。当公文类的内容或状态发生变化时,关联此OfficeDoc类对象的相应的DocExplorer对象都要更新其自身的状态。一个OfficeDoc对象能够关联一组DocExplorer对象。当OfficeDoc对象的内容或状态发生变化时,所有与之相关联的DocExplorer对象都将得到通知,这种应用被称为观察者模式。以下代码写在一个C++源文件中,能够正确编译通过。

[C++代码]

#include<iostream>

const OBS_MAXNUM=20//最多与OfficeDoc对象相关联的DocExplorer对象个数

(1)

class DocExplorer //关注OfficeDoc公文对象的类

public:

DocExplorer( (2) *doc); //构造函数

(3) void update(OfficeDoc *doc)=0; //更新自身状态的函数

//其他相关属性和方法省略

class OfficeDoc//公文类

private:

DocExplorer *myObs[OBS_MAXNUM];

//关注此公文类的DocExplorer类对象指针数组

int index;//与OfficeDoc对象关联的DocExplorer对象的个数

public:

OffiCeDoc()

index=0;

void attach(DocExplorer *o)

//将一DocExplorer对象与OfficeDoc对象相关联

if(index>=OBS_MAXNUM||o==NULL)return;

for(int loop=0;loop<index;loop++)

if(myOhs[100p]==o)return;

myObs[index]=o;

index++;

void detach(DocExplorer *o)

//解除某DocExplorer对象与OfficeDoc对象的关联

if(o==NULL)return;

for(int loop=0;loop<index;loop++)

if(myObs[100p]==o)

if(loop<=index-2)myObs[100p]=myObs[index-1];

myObs[index-1]=NULL;

index--;

break;

private:

void notifyObs()//通知所有的DocExplorer对象更改自身状态

for(int loop=0;loop<index;loop++)

myObs[loop]-> (4) ;//DocExplorer对象更新自身状态

//其他公文类的相关属性和方法

DocExplorer::DocExplorer(OfficeDoc *doc)(//DocExplorer类对象的构造函数

doc-> (5) ; //将此DocExplorer对象与doc对象相关联

 

(3)处填()。

答案

参考答案:virtual

阅读理解

阅读理解。

     Mr. Ellis is very old. He has seen many changes in his home town.   

     He knows that things are different now. But he never forgets the old days. He likes to talk about them. He

often talks about his favourite (最喜欢的) birds, the robins (一种小小鸟--鸫). "When I was a boy, these houses were not here. There were wide fields and tall trees. Every spring robins would come. Thousands of them

would fly up to the north from the south. They spent the winter in the south. Some would build their nests (巢)

in the trees near our houses. Then people started to cut down trees, and they built more houses. The robins

stopped coming. They couldn't build their nests near our houses because there were no trees."   

     "Now there are too many houses and too many roads. There are no places for the robins. They do come

any more (不再)."

1. Mr. Ellis often talks about _______.   

A. his old house

B. the old days   

C. his life now

D. his family

2. The birds, the robins, spent the winter in ________.   

A. the south

B. the west   

C. the north

D. the east

3. _______ built the nests in the trees.   

A. Mr. Ellis

B. Some people   

C. The robins

D. Some dogs

4. Then people ________ trees because they wanted to build more houses.   

A. cut down

B. planted

C. bought

D. watered

5. From the passage (短文) we can know that ________.   

A. Mr. Ellis likes his new life now   

B. there were many houses there in the old days   

C. the robins can make their nests without trees   

D. Mr. Ellis is not happy with the changes there

单项选择题