问题 单项选择题

若有以下程序:
#include <iostream>
using namespace std;
class Base

private:
int a,b;
public:
Base(int x, int y)

a=x;
b=y;

void show()

cout<<a<<", "<<b<<end1;

;
class Derive : public Base

private:
int c, d;
public:
Derive(int x, int y, int z,int m):Base(x,y)

c=z;
d=m;

void show()

cout<<c<<", "<<d<<end1;

;
int main ( )

Base b(50,50) ,*pb;
Derive d(10,20,30,40);
pb=&d;
pb->show );
return 0;

A.10,20

B.30,40

C.20,30

D.50,50

答案

参考答案:A

解析: 本题考核基类指针的使用。本题首先定义了一个基类Base和一个由Base派生出来的派生类Derive。在主函数中,定义了一个基类Base指针吵和基类对象b,还定义了派生类Derive的对象do然后将派生类对象d的地址赋值给指向基类Base的指针pb。由于Derive是Base的子类型,因此允许上述赋值。但这时指针pb只能使用从基类Base继承的成员,即当pb指向d对象时,pb->show还是调用基类Base的成员函数show()。所以程序最后输出的是对象d中对基类成员的初始化值,即10,20。

阅读理解

阅读理解。

     Mr.Ma, a famous mental doctor from Beijing once said at an important meeting, "Now many young

students can have problems with their minds. Some students become worried because they have to study

very hard. Others have trouble getting on well with people around them like their parents and classmates.

Parents and teachers should care more about this problem."

     Then Mr.Ma gave some examples. One patient, a middle school student from Xi'an was doing badly

in his lessons. He thought his teachers and friends often laughed at him, and he became so nervous and

worried that one night he left his homes without telling parents. Another student, a 14-year-old schoolgirl

from Shanghai, was very afraid of exams. While she was reading the exam paper, she couldn't think of

anything to write.

     A recent report from Jiefang Daily says about 18% of the young students in Shanghai have mental

problems. They often fell worried and very unhappy. Unluckily many of them won't go and ask for help.

Some think they will look stupid if they go to see a doctor. Others won't talk about their secrets. At the

end of the meeting, Mr.Ma offered some good ideas to young people.

Talk to your parents or teacher often.

Take part in group activities.

Try to get on well with the people around you.

Go to see a doctor if you often feel unhappy.

1. The students who often become worried or have trouble getting on with others may have ________.

A. no parents         

B. no secrets

C. poor memories      

D. mental problems

2. The schoolgirl's problem happened whenever she ________.

A. studied very hard    

B. had exams

C. talked with her parents  

D. went to see the doctor

3. Some of those with mental problems won't ask for help because ________.

A. they don't want  to tell their secrets to others

B. their parents are too busy to look after them

C. doctors can't help them with the problems

D. they can do with the problems themselves

4. The underlined word "stupid" in this passage means ________.

A. pretty  

B. happy

C. not clever

D. not friendly

5. According to the last part, which of the followings is a good idea?

A. It's important for children to live with their parents.

B. It's helpful for people to see doctors every day.

C. It's useful for students to keep quiet in class.

D. It's necessary for young people to have group activities.

解答题