c++考试复习题a

上传人:第*** 文档编号:32806026 上传时间:2018-02-12 格式:DOC 页数:9 大小:43KB
返回 下载 相关 举报
c++考试复习题a_第1页
第1页 / 共9页
c++考试复习题a_第2页
第2页 / 共9页
c++考试复习题a_第3页
第3页 / 共9页
c++考试复习题a_第4页
第4页 / 共9页
c++考试复习题a_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《c++考试复习题a》由会员分享,可在线阅读,更多相关《c++考试复习题a(9页珍藏版)》请在金锄头文库上搜索。

1、(考试时间 90 分钟,满分 100 分)一、选择题(每小题 2 分,共 70 分)(1)下列变量名中, ( )是合法的。A)CHINA B)byte-size C)double D)A+a(2)下列各种函数中, ( )不是类的成员函数A)构造函数 B)析构函数 C)友元函数 D)拷贝构造函数(3)软件设计中模块划分应遵循的准则是( ) 。A)低内聚低耦合 B)高内聚低耦合 C)低内聚高耦合 D)高内聚高耦合(4)下列( )是正确的语句。A) ; B)a=17 C)x+y D)cout1; I-=2)cout double _由此可知A)这可能是一个函数模板的声明B)这可能是一个类模板的声明C

2、)这既可能是一个函数模板的声明,也可能是一个类模板的声明D)这肯定是一个错误的模板声明(26)有如下 4 个语句: coutgetPI();和 coutgetPI();和 coutgetPI();D)coutusing namespace std;class VACpublic; int f() const return 3; int f() return 5;Int main()VAC v1; const VAC v2;coutusing namespace std;class Base int x; public;Baseint n=0; x(n)coutUsing namespace s

3、td;Class Amountint amount;public;Amount(int n=0): amount(n)Int getAmount()constreturn amount;Amount &operator +=(Amount a)amount+=a.amount; return ; ;int main()Amount x(3),y(7);x+=y; coutusing namespace std;class GApublic;virtual int f()retum l;class GB: public GApublic;virtual int f()return 2;void

4、show(GA g)coutusing namespace std;class Basepublic;int m,n; ;class Derived1: _Base;class Derived2: public Derived1public:void SetMN(int M, int N) M=M; n=N; int GetSumMN() retum (m+n); ;int main()Derived2 objD;objD.SetMN(3,4);coutusing namespace std;class Baseint b; public;Base(int i) b=i; void disp(

5、)cout#include #include using namespace std;class PhoneMumberpublic;void setNumber(string number) this-number=number; /重载流插入操作符friend_ (ostream &output, const PhoneNumber &num) output#include using namespace std;class TwoDShape /二维图形类char name20;public;TwoDShape(char *n=unknown)strcpy(name, n); char

6、*getNa:ne() return name; _=0;class Rec : public TwoDShapedouble width, height;public;Rec (double w=0.0, double h=0.0):TwoDShape(rectamgle) 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 getName()area()using namespace std;_T1 i; T2 j; public;dataClass(T1 a T2 b) i = a; j=b; void show() cout ob1(10, 0.23);dataClassob2(X, my data);ob1.show();ob2.show();retum 0; 请将程序补充完整,使程序在运行时输出:10, 0.23X, my data

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 工程造价

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号