紫金学院C++考试范围预估.docx
《紫金学院C++考试范围预估.docx》由会员分享,可在线阅读,更多相关《紫金学院C++考试范围预估.docx(19页珍藏版)》请在冰点文库上搜索。
紫金学院C++考试范围预估
范围预估
一、选择题。
(2*10)
1、3道面向过程(第三章至第六章),其中2道与指针有关。
2、7道面向对象(第八章到第十二章),大致重点:
运算符重载、析构、构造、和友元等。
注:
均来自习题集。
二、填空题。
(1*10)
涉及考点:
结构体(第七章:
给结构体成员赋值)、三种继承方式后的权限类型(第十一章)、多态(第十二章:
实现手段、区别),字符串函数(第五章:
strlen、strcpy等)。
注:
主要参考习题集并大致了解书本介绍。
三、判断题。
(1*5)
习题集第八章至第十二章中判断题选其中5道,大概都细看之。
四、程序填空。
(2*10)
1、友元。
(下为可能出现的原题)
2、构造函数。
(下为可能出现的原题)
五、填结果。
(5*5)
1、不同存储类型对象调用构造、析构原则
2、派生类,构造函数调用顺序
六、编程题。
(10*2)
1、上机题(书本十一章——9)★★★★★
2、#include
3、#include
4、usingnamespacestd;
5、classTeacher
6、{
7、public:
8、Teacher(stringna,inta,stringsex,stringtit,stringad,stringt);
9、voiddisplay();
10、
11、protected:
12、stringname;
13、intage;
14、stringsex;
15、stringtitle;
16、stringaddr;
17、stringtel;
18、};
19、Teacher:
:
Teacher(stringna,inta,stringsex,stringtit,stringad,stringt):
name(na),age(a),sex(sex),title(tit),addr(ad),tel(t){}
20、voidTeacher:
:
display()
21、{
22、cout<<"name:
"<23、cout<<"age:
"<24、cout<<"sex:
"<25、cout<<"title:
"<
26、cout<<"address:
"<27、cout<<"tel:
"<28、}
29、classCadre
30、{
31、public:
32、Cadre(stringna,inta,stringsex,stringp,stringad,stringt);
33、voiddisplay();
34、
35、protected:
36、stringname;
37、intage;
38、stringsex;
39、stringpost;
40、stringaddr;
41、stringtel;
42、};
43、Cadre:
:
Cadre(stringna,inta,stringsex,stringp,stringad,stringt):
name(na),age(a),sex(sex),post(p),addr(ad),tel(t){}
44、voidCadre:
:
display()
45、{
46、cout<<"name:
"<47、cout<<"age:
"<48、cout<<"sex:
"<49、cout<<"post:
"<50、cout<<"address:
"<51、cout<<"tel:
"<52、}
53、classTeacher_Cadre:
publicTeacher,publicCadre
54、{
55、public:
56、Teacher_Cadre(stringna,inta,stringsex,stringtit,stringp,stringad,stringt,floatw);
57、voidshow();
58、
59、private:
60、floatwage;
61、};
62、Teacher_Cadre:
:
Teacher_Cadre(stringna,inta,stringsex,stringt,stringp,stringad,stringtel,floatw):
Teacher(na,a,sex,t,ad,tel),Cadre(na,a,sex,p,ad,tel),wage(w){}
63、voidTeacher_Cadre:
:
show()
64、{
65、Teacher:
:
display();
66、cout<<"post:
"<:
post<67、cout<<"wages:
"<68、}
69、intmain()
70、{
71、Teacher_Cadre
72、xiaoming("小明",25,"男","高级工程师","开发工程师","南京","12345678",1234.5);
73、xiaoming.show();
74、return0;
75、}
12.4★★★
76、#include
77、usingnamespacestd;
78、classShape
79、{
80、public:
81、virtualdoublearea()const=0;
82、};
83、classCircle:
publicShape
84、{
85、public:
86、Circle(doubler):
radius(r){}
87、virtualdoublearea()const{return3.14159*radius*radius;};
88、
89、protected:
90、doubleradius;
91、};
92、classRectangle:
publicShape
93、{
94、public:
95、Rectangle(doublew,doubleh):
width(w),height(h){}
96、virtualdoublearea()const{returnwidth*height;}
97、
98、protected:
99、doublewidth,height;
100、};
101、classTriangle:
publicShape
102、{
103、public:
104、Triangle(doublew,doubleh):
width(w),height(h){}
105、virtualdoublearea()const{return0.5*width*height;}
106、
107、protected:
108、doublewidth,height;
109、};
110、voidprintArea(constShape&s)
111、{
112、cout<113、}
114、
115、intmain()
116、{
117、Circlecircle(12.6);
118、cout<<"areaofcircle=";
119、printArea(circle);
120、Rectanglerectangle(4.5,8.4);
121、cout<<"areaofrectangle=";
122、printArea(rectangle);
123、Triangletriangle(4.5,8.4);
124、cout<<"areaoftriangle=";
125、printArea(triangle);
126、return0;
127、}
12.5★★★
128、#include
129、usingnamespacestd;
130、classShape
131、{
132、public:
133、virtualdoublearea()const=0;
134、};
135、classCircle:
publicShape
136、{
137、public:
138、Circle(doubler):
radius(r){}
139、virtualdoublearea()const{return3.14159*radius*radius;};
140、
141、protected:
142、doubleradius;
143、};
144、classSquare:
publicShape
145、{
146、public:
147、Square(doubles):
side(s){}
148、virtualdoublearea()const{returnside*side;}
149、
150、protected:
151、doubleside;
152、};
153、
154、classRectangle:
publicShape
155、{
156、public:
157、Rectangle(doublew,doubleh):
width(w),height(h){}
158、virtualdoublearea()const{returnwidth*height;}
159、
160、protected:
161、doublewidth,height;
162、};
163、
164、classTrapezoid:
publicShape
165、{
166、public:
167、Trapezoid(doublet,doubleb,doubleh):
top(t),bottom(t),height(h){}
168、virtualdoublearea()const{return0.5*(top+bottom)*height;}
169、
170、protected:
171、doubletop,bottom,height;
172、};
173、
174、classTriangle:
publicShape
175、{
176、public:
177、Triangle(doublew,doubleh):
width(w),height(h){}
178、virtualdoublearea()const{return0.5*width*height;}
179、
180、protected:
181、doublewidth,height;
182、};
183、intmain()
184、{
185、Circlecircle(12.6);
186、Squaresquare(3.5);
187、Rectanglerectangle(4.5,8.4);
188、Trapezoidtrapezoid(2.0,4.5,3.2);
189、Triangletriangle(4.5,8.4);
190、Shape*pt[5]={&circle,&square,&rectangle,&trapezoid,&triangle};
191、doubleareas=0.0;
192、for(inti=0;i<5;i++)
193、{
194、areas=areas+pt[i]->area();
195、}
196、cout<<"totolofallareas="<197、return0;
198、}
注:
三道其中之一。
2、