- 39
- 0
- 约6.44千字
- 约 20页
- 2017-08-16 发布于河南
- 举报
c期末复习(程序填空题)1(Cfinalreview(fillintheblanks)1)
c++期末复习(程序填空题)1(C++ final review (fill in the blanks) 1)
C++ final review (cloze)
1. Fill in the appropriate lines at the bottom line and complete the definition of the member functions in the class.
Class A{
Int * a;
Public:
A (int, aa=0) {
A=_________; / / dynamic object is initialized with AA to a
}
~ (A) {_________}// release dynamic storage space;
};
Answer: new, int (AA), delete, a
2. Here is a function template for calculating the sum of two vectors. Complete the function template definition by filling in the appropriate lines at the bottom line.
Include iostream.h
Templateclass T
T* f (T*, a, T*, B, int, n)
{
T* c=_________;
For (int i=0; in; i++)
C I =_________;
Return c;
}
Void, main ()
{
Int, a [5] ={1,2,3,4,5}, B [5] ={10,20,30,40}, *p;
P=f (a, B, 5);
For (int i=0; i5; i++)
Coutp[i]endl;
}
Answer: new int[n]
A [i] +b[i]
3, define the functions of the class date with default values (January 1, 2004) and copy constructors
#include iostream.h
Class date
{private:
Int, year, month, day;
Public:
Date ()
{year=y; month=m; day=d;}
Date ()
{year=d1.year; month=d1.month; day=d1.day;}
};
Void, main ()
{date D1 (2004,10,8);
Date d2=d1;
}
Answer: int, y=2004, int, m=1, int, d=1
Const date d1
4. The bottom line of the following procedure is filled with the proper words so that the execution of the program is 10.
#include iostream.h
Class base
{int X;
Public:
Void init (int n {X=n);} / / set X
Int Getnum (return) {X*X+1}; / / X value
};
Void, main ()
{base test;
Test.init (3);
Couttest.Getnum () endl;
}
5. Fill in the appropriate words at the bottom line of the following procedure and complete the definition of the member functions in the class.
#include iostream.h
Class box
{private:
Int, color, upx, upy, lowx, lowy;
Public:
Friend, int, samecolor (line, a, box, B);
Void, set, _color (int, c) {color=c;}
Void, define, _box (int, x1, int, Y1, int, X2, int, Y2)
{upx=x1; upy=y1;}
};
Class line
{private:
Int, color, startx, starty, len;
Public:
Friend, int, samecolor (lin
您可能关注的文档
- 23《称象》教学设计之四(23 as teaching design four).doc
- 28_小伙伴的教学反思3(Reflections on the teaching of 28_ buddy 3).doc
- 24《东方之珠》(24 the Oriental Pearl ).doc
- 23《美丽的小兴安岭》教学设计之九(23 beautiful little Xingan Ling teaching design nine).doc
- 2d游戏设计浅谈(Discussion on game design 2D).doc
- 2到3岁宝宝语言学习游戏(2 to 3 years old baby language learning games).doc
- 2d网络游戏排行榜排行(2D online game Ranking Ranking).doc
- 2春雨的色彩教学反思(Reflection on the 2 spring color teaching).doc
- 2b论文(2B paper).doc
- 3 2011年6月25日电子商务员考证理论真题答案(June 25, 32011 Electronic Commerce member theory research Zhenti answer).doc
- 2026年长春事业单位联考备考题库发布时间有完整答案详解.docx
- 2026广西北海市合浦县民政局招录城镇公益性岗位人员11人备考题库及答案详解(最新).docx
- 2026江苏南京邮电大学招聘(人事代理)4人备考题库(第二批)精编答案详解.docx
- 2026年湖口县公安局交通管理大队公开招聘交通协管员备考题库完整答案详解.docx
- 2026年长春事业单位联考备考题库发布时间及一套答案详解.docx
- 2026年福建莆田市公安局城厢警务辅助人员招聘13人备考题库及参考答案详解1套.docx
- 2026广东佛山狮山镇大圃诚聘地理美术化学英语教师备考题库及答案详解(考点梳理).docx
- 2026广东中山市公安局南头分局招聘辅警3人备考题库完整答案详解.docx
- 2026年芜湖市文化和旅游局所属事业单位公开招聘编外聘用人员备考题库及答案详解参考.docx
- 2026广西北海市合浦县纪委监委招录公益性岗位人员1人备考题库及答案详解1套.docx
最近下载
- 2025年演出经纪人后疫情时代国际演出物流的变革与趋势专题试卷及解析.pdf VIP
- 中招联合-项目经理全流程操作手册(1).docx VIP
- 2024年河北省石家庄市中考地理试题卷(含答案解析).docx
- 煤矿安全工作汇报材料汇报材料.doc VIP
- 2025初中数学中考复习 专题15与圆有关的位置关系(3大模块知识梳理+9个考点+5个重难点+1个易错点)(原卷版).pdf VIP
- 2025年母婴保健技术资格证考试试题及答案.docx
- 2026届山西省侯马市中考押题数学预测卷含解析.doc VIP
- Sr掺杂分子印迹TiO2光催化剂的制备及降解羟苯乙酯性能研究.docx VIP
- 王力语言学史(一).doc VIP
- 输变电工程标准工艺(变电工程土建分册)2022版.pdf VIP
原创力文档

文档评论(0)