问题 填空题

使用VC6打开考生文件夹下的工程test7_1,此工程包含一个源程序文件test7_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:
Constructor1
Constructor1
Constructor1
Destructor
Constructor2
Destructor
x=0
x=5
Destructor
Destructor
源程序文件test1_1.cpp清单如下:
#include<iostream.h>
class B

int X;
public:
B()X=0;cout<<"Constructorl"<<endl;
B(int i)x=i;cout<<"Constructor2"<<endl;
~B()cout<<"Destructor"<<endl;
/**********found*********/
~B(int i)cout<<i<<"be Destructor"<<endl;
void print()cout<<"x="<<x<<endl;
;
void main()

B *ptr;
ptr=new B[2];
/**********found*********/
ptr[0]=B(0);
ptr[1]=B(5);
/**********found********/
for(int i=0; i<2;)
ptr[i].print();
delete []ptr;

答案

参考答案:
(1)错误:~B(int i){cout<<"be Destructor"<<endl;}
正确:应将其删除
(2)错误:ptr[0]=B(0);
正确:ptr[0]=B();
(3)错误:for(int=0;i<2;)
正确:for(int i=0;i<2;i++)

解析:
(1)主要考查考生对析构函数特性的掌握,析构函数不能带参数也不能重载,一个类中只能定义一个析构函数,因为析构函数在删除对象的时候被默认调用,如果含有多个析构函数则可能引起多次删除产生的意外错误;
(2)主要考查考生对构造函数与函数重载的掌握,由输出结果可知其应该调用不带参数的构造函数B();
(3)主要考查考生对for循环语句的使用,如果在for循环中不写第三个表达式就意味着该循环一直会进行下去,因为 i的值总是小于2(在for循环体中对i进行操作也可以)。

阅读理解

阅读短文,选择正确答案。

      China Youth says that more and more girl students have entered colleges to study in the recent few years.

As we know, once the number of boys was larger than that of girls and boys did much better than girls in our

country for a long time. Now, things have changed a lot.

      In recent years, the proportion of girl students is growing fast. In 1998, about 39.7% of college students

were girls. In 2000, it was 41.07% and in 2001, the number was 42.14%.

      There are several reasons for this.

      Firstly, there is little difference between boys and girls in their intelligence (智力). That's to say, girls are as

clever as boys. And boys have more interests than girls, so they may not always do well in their study.

      Secondly, girls are more careful than boys. They work harder at school and they do better in all exams.

      Another reason is that with the development of society, people pay more and more attention to girls'

education.

1. China Youth says that more and more ______. [ ]

A. boys are clever than girls

B. boys can't go to school

C. girls have entered colleges

D. girls begin to study at school

2. 42.14% refers to (指) the number of ______. [ ]

A. girls at schools in 1998

B. girls in colleges in 2001

C. boys at schools in 2001

D. boys in colleges in 1998

3. The writer gave us ______ reasons to explain the question. [ ]

A. two

B. three

C. four

D. five

4. What does the underlined word "proportion" mean in Chinese? [ ]

A. 身高

B. 比例

C. 特性

D. 速度

5. Which of the following sentences is TRUE?[ ]

A. Boys may not do well in their study as girls because they don't like studying.

B. Boys are much cleverer than girls because they're interested in many things.

C. Girls' intelligence is the same as boys'.

D. Girls study harder, but they couldn't get higher marks than boys.

单项选择题