问题 填空题

使用VC6打开考生文件夹下的工程test25_1,此工程包含一个源程序文件test25_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:
privatel from derived1:30
privatel from derived2:30
源程序文件test25_1.cpp清单如下:
/***************found******************/
include<iostream.h>
class base

protected:
int privatel;
public:
base(int p)privatel=p;
;
/****************found*******************/
class derived1:public base

public:
derivedl(int p1):base(p1);
int get_private()return private1;

class derived2:virtua1 public base

public:
derived2(int p2):base(p2);
int get_private()return private1;
;
class derived12:public derived1,public derived2

public:
/****************found*******************/
derived12(int p1,int p2,int pb):derived1(p1), base(pb), derived2(p2);
;
void main()

derived12 d(10,20,30);
cout<<"privatel from derived1:"<<d.derived1::get_private();
cout<<"\nprivatel from derived2:"<<d.derived2::get_private();
cout<<endl;

答案

参考答案:
(A)错误:include<iostream.h>
正确:#include<iostream.h>
(B)错误:class derivedl:public base
正确:class derivedl:virtual public base
(C)错误:derivedAB(int pA,int pB,int pb):derivedl(pA),base(pb),derivedB(pB){};
正确:derivedAB(int pA,int PB,int Pb):derivedl(PA),derivedB(pB),base(Pb){};

解析:
(1)主要考查考生对于include关键字的掌握,它的正确使用是#include;
(2)主要考查考生对于虚基类的使用,为了正确的显示结果,这里应该使用虚基类的定义,这样在调用函数的时候就可以不产生二义性;
(3)主要考查考生对于初始化参数表中赋值顺序的掌握,它是按照从右至左依次赋值的。

阅读理解

阅读理解

     Robby was 11 when his mother dropped him off for his first piano lesson. I prefer students to begin

at an earlier age. Robby said that it had always been his mother's dream to hear him play the piano, so

I took him on as a student.

     Robby tried and tried while I listened and encouraged him and gave him more instructions. But he

just did not have any inborn ability.

     I only saw his mother from a distance. She always waved and smiled but never came in.  Then one

day Robby stopped coming to our lessons. I thought about calling him but I guessed he had decided to

try something else.

     I was also glad that he stopped coming for the sake of my career. However, several weeks before

the recital (演奏会) of my students, Robby came,telling me that he never stopped practicing and begged

me to allow him to take part in it. I agreed, but I made him perform last in the program, so I could save

his poor performance through my "curtain closer".

     I was surprised when he announced that he had chosen one piece of Mozart's. However, never had

I heard a piece of Mozart's played so well by someone at his age.

     I ran up and put my arms around Robby in joy. "I've never heard you play like that, Robby! How

could you do it?"

     "Well, Miss Hondorf. Do you remember I told you my mom was sick? Actually she died this

morning. She was born deaf, so tonight was the first time she could hear me play. I wanted to make it

special. I knew I could."

1. Why might Robby have stopped coming to piano lessons suddenly?

A. He lost heart and believed that he would never make it.

B. His mother might have been seriously ill.

C. He thought that his teacher disliked him.

D. His mother died and he didn't need to play any longer.

2. We can know from the passage that _________.

A. the writer thought students shouldn't begin playing the piano too early

B. the writer thought that Robby had given up his piano lessons

C. only by practicing at home did Robby learn to play well

D. no one else could play the piece of Mozart's as well as Robby

3. From the underlined sentence, we can infer that _________.

A. the writer looked down upon Robby and disliked him

B. the writer thought Robby was a bad advertisement for her teaching

C. with Robby in the recital, the other children couldn't play well

D. the writer couldn't teach so many students at a time

4. The writer made Robby perform last because _________.

A. the one who performs last always performs very well

B. Robby asked the writer to do so

C. she wanted to do something to save a poor performance

D. Robby thought his mother would come at last

单项选择题 A1/A2型题