问题 填空题

下面程序的输出结果为:Base:: fun,请将程序补充完整。
#include <iostream.h>
class Base
public:
【12】 fun()cout<<"Base::fun"<<end1:
class Derived : public Base
public:
【13】 fun() cout<<"Derived::fun"<<end1;
;
int main() Base a,*pb;
Derived b;
pb = &b;
pb->fun();
return 0;

答案

参考答案:[l2]virtual void [13]void

解析: 本题考核虚函数的使用。在C++中,一个基类指针(或引用)可以用于指向它的派生类对象,而且通过这样的指针(或引用)调用虚函数时,被调用的是该指针(或引用)实际指向的对象类的那个重定义版本,这样的调用称为多态调用。基类Base和派生类Derived中都定义了成员函数fun,但是有不同的实现。程序最后输出的结果为:Base::fun,表明通过对象指针pb调用的函数版本为派生类中定义的,只有把基类的fun函数定义为虚函数,才能满足要求。同时通过函数fun的定义可知函数的返回类型为void。

单项选择题
阅读理解

One suicide and three attempted ones that left two seriously injured, all by middle school students in Shanghai last week, cast a gloom (忧郁) over an otherwise happy beginning of a new term there. The terrible things took place even as the Ministry of Education and China Central Television organized the first lesson on TV about personal safety for students last Monday, the first day of the new semester. Such things suggest that this first lesson is more than necessary. Not only should kids be taught how to protect themselves in times of emergency, they should also be made aware of the value of tile2 One student was prevented from killing himself from his school building. He said he just could not accept the fact of not being able to go tip to a higher grade with his classmates, and thus considered life meaningless. Another 12-year-old boy who jumped off a building to his death was said to have been a good student, and no one could say why he chose to end his life. Obviously, their inner worlds were seriously affected. But when they chose to take their own lives, their irresponsible choice was clearly the result of a lack of adequate understanding of the value of life.

The ancient sage Confucius (孔子) stressed that one must protect even one's hair and skin from being hurt. He meant that the sense of responsibility for one's parents was important as far as the value of life was concerned. When we talk about the enthusiasm of making contributions to our motherland, we are referring to values that constitute the nobler part of the meaning of life. The value of life should be far beyond the concern for personal interest.

Undoubtedly, those kids who chose to take their own lives were faced only with their own sadness that they could not overcome. If they had a little concern for their parents, for their parents' expectations of them or for their own potential contributions to this world in the future, they would not have gone that far. Difficulties or sufferings are supposed to help kids develop their sense of responsibility and thus help them better understand the value of life.

Too much attention and care from their parents and grandparents have made most of the only children self-centered. Many think it is natural that they deserve to be taken care of by others in whatever way they want. They expect to have their problems solved by their parents or someone else. With such a false sense, they fail to grasp the tough reality of life. They suffer from the illusion (幻觉) that their life should be nothing but plain sailing, Whenever the illusion is broken, they can hardly gather enough courage to face life as it is. So a hotline is indeed necessary to help those kids who find it hard to accept the tough reality of life. But parents and teachers also need to take lessons from the things. They need to know that life should not always be sugar-coated for kids; they should be made to taste the bitter side too as early as possible.

小题1:From the passage we know that _________.

A.four students took their lives in Shanghai last week

B.being unable to catch up with other classmates led to the 12-year-old boy killing himself

C.the importance of life lies in the sense of responsibility for parents

D.parents are supposed to tell the kids the bitter side of life as well as the sweet side小题2:What mainly causes those kids to take their own lives is that _________.

A.they are worried that they may fall behind others in studies

B.they lack the respect for their parents

C.they may be physically healthy, but mentally unhealthy

D.their parents expect too much from them小题3:Which of the following would be the best title of the passage?

A.An irresponsible choice.

B.The value of life.

C.Weak-minded generation.

D.The reality of life.