问题 填空题

下面程序的运行结果是 【9】
#include <iostream>
using namespace std;
class count

static int n;
public:
count()

n++;

static int test()

for(int i=0;i<4;i++)
n++;
return n;

;
int count::n = O;
int main()

cout<<count:: test()<<" ";
count c1, c2;
cout<<count:: test()<<endl;
return 0;

答案

参考答案:410

解析: 本题主要考查C++类中静态数据成员的使用。题目程序首先定义了类count,其内部含有private 类型数据成员static int n;同时含有public 类型构造函数 count()和静态成员函数static int test(),这两个函数的功能分别是为对象申请系统资源并将静态数据成员n加1和将静态数据成员n加4。主函数前,程序将静态数据成员n初始化为0,该数据成员为所有类count 的对象所共有的数据成员;主函数中程序首先执行静态成员函数test() (由于test 声明为 static,因此其调用时无需通过具体对象),其执行过程中,静态数据成员n应该加4变成n:4,因此此处输出为4;此后程序创建对象c1和c2,由于在每次创建过程中都要调用构造函数count(),而每次调用count()函数后,静态数据成员n值都会加1。因此,创建两个对象之后,n值变为n=6:再次执行test()函数后,n的值再次加4,因此变为n=6+4=10。故程序全部执行后,变量n值变为10,而中间程序输出为“410”。

单项选择题

Modern liberal opinion is sensitive to problems of restriction of freedom and abuse of power. (1) , many hold that a man can be injured only by violating his will, but this view is much too (2) . It fails to (3) the great dangers we shall face in the (4) of biomedical technology that stems from an excess of freedom, from the unrestrained (5) of will. In my view, our greatest problems will be voluntary self-degradation, or willing dehumanization, as is the unintended yet often inescapable consequence of sternly and successfully pursuing our humanization (6) .

Certain (7) and perfected medical technologies have already had some dehumanizing consequences. Improved methods of resuscitation have made (8) heroic effort to "save" the severely ill and injured. Yet these efforts are sometimes only partly successful: They may succeed in (9) individuals, but these individuals may have sever brain damage and be capable of only a less-than-human, vegetating (10) . Such patients have been (11) a death with dignity. Families are forced to bear the burden of a (12) "death watch".

(13) the ordinary methods of treating disease and prolonging life have changed the (14) in which men die. Fewer and fewer people die in the familiar surroundings of home or in the (15) of family and friends. This loneliness, (16) , is not confined to the dying patient in the hospital bed. As a group, the elderly are the most alienated members of our society: Not yet (17) the world of the dead, not deemed fit for the world of the living, they are shunted (18) . We have learned how to increase their years, (19) we have not learned how to help them enjoy their days. Yet we continue to bravely and feverishly push back the frontiers (20) death.

3()

A.identify

B.promote

C.recognize

D.assist

问答题 简答题