问题 填空题

如下程序声明了一个二维图形类TwoDShape,从其派生出矩形类Rec。 #include<iostream> #include<string> using namespaee std, class TwoDShape{// 二维图形类 char name[20]; public: TwoDShape (char * n="unknown") { strcpy(name, n); } Char * getName(){return name;} 【 】 =0; }; class Rec: public TwoDShape{ double width, height public: Rec(double w-=0. 0,double h=0. 0):TwoDShape("rectangle") { width=w; height=h; } double getWidth() {return width;} double getHeight() {return height;} double area() {return width * height;} }; int main() { TwoDShape * shape; Shape=new Rec(2.1,3.0); cout<<"object is"<<shape->getName()<<"\n"; cout<<"Area is"<<shape->area()<<"\n"; return 0 } 请将程序补充完整,使程序在运行时输出: abject is triangle Area is 6.3

答案

参考答案:virtual double area()

解析:这里需要添加一个纯虚函数,即virtual double area()=0。

完形填空

People wear hats for three main reasons: protection, communication, and decoration.

Protection. People first began to wear hats to ___1___ themselves from the climate. In hot, sunny climates, wide-edged hats provide ___2___ from the sun. In cold climates, people often wear wool hats. In some regions, people wear a variety of protective hats, ___3___ the season. They may wear a wool hat in winter, a rain hat in spring or fall, and a wide-edged hat in summer. Hats also provide protection in certain ___4___. Construction workers, football players, military personnel, and people in many other fields wear metal or plastic helmets(头盔)for protection from ___5___.

Communication. Hats can communicate various things about the people who wear them. The hats of coal miners, cowboys and firemen indicate the wearer's ___6___. Students may wear a mortarboard (学位帽) to show they are graduating from high school or college.

Decoration. Most people wear a hat that they believe makes them look attractive, ___7___ the hat's main purpose may be protection or communication. Many protective hats are attractive and stylish. Even the caps of police officers and military personnel are designed to ___8___ the wearer's appearance. Certain decorative hats are worn as a (n) ___9___. In Scotland, for example, people wear a cap called a tam-o'-shanter that is part of their national costume (服装). Many people change their style of hat from time to time because they feel more ___10___ when keeping up with the latest fashion.

1. A. defend     B. protect    C. prevent   D. hide

2. A. shade    B. shadow      C. security    D. cover

3. A. resulting from  B. basing upon  

C. relating to  D. depending on

4. A. seasons      B. climates     C. activities    D. communities

5. A. injury     B. destruction   C. harm   D. pollution

6. A. experience     B. occupation  C. personality  D. education

7. A. as   B. unless   C. though  D. because

8. A. change    B. increase   C. display   D. improve

9. A. tradition  B. label    C. honour     D. fashion

10. A. sociable    B. informal    C. attractive    D. noble

问答题 简答题