问题 填空题

下面程序的运行结果是 【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”。

单项选择题
单项选择题

The effect of the baby boom on the schools helped to make possible a shift in thinking about the role of public education in the 1920’s. In the 1920’s, but especially (1) the Depression of the 1930’s, the United States experienced a (2) birth rate. Then with the prosperity (3) on by the Second World War and the economic boom that followed it, young people married and (4) households earlier and began to (5) larger families than had their (6) during the Depression. Birth rates rose to 102 per thousand in 1946, 106.2 in 1950, and 118 in 1955. (7) economics was probably the most important (8) , it is not the only explanation for the baby boom. The increased value placed (9) the idea of the family also helps to (10) this rise in birth rates. The baby boomers began streaming (11) the first grade by the mid-1940’s and became a (12) by 1950. The public school system suddenly found itself (13) The wartime economy meant that few new schools were buih between 1940 and 1945. (14) , large numbers of teachers left their profession during that period for better-paying jobs elsewhere.

(15) , in the 1950’s, the baby boom hit an antiquated and inadequate school system. Consequently, the custodial rhetoric of the 1930’s no longer made (16) ; keeping youths ages sixteen and older out of the labor market by keeping them in school could no longer be a high (17) for an institution unable to find space and staff to teach younger children. With the baby boom, the focus of educators (18) turned toward the lower grades and back to basic academic skills and (19) . The system no longer had much (20) in offering nontraditional, new, and extra services to older youths.

5()

A.increase

B.raise

C.erect

D.generate