ImageVerifierCode 换一换
格式:DOC , 页数:61 ,大小:165KB ,
资源ID:7730265      下载积分:10 金币
验证码下载
登录下载
邮箱/手机:
图形码:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/7730265.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请。


权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4009-655-100;投诉/维权电话:18658249818。

注意事项

本文(浙大2013年下半学期面向对象离线离线作业.doc)为本站上传会员【pc****0】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

浙大2013年下半学期面向对象离线离线作业.doc

1、浙江大学远程教育学院 《面向对象程序设计》课程作业 姓名: 学 号: 年级: 2013(春)计算机科学与技术(专本(业余)) 学习中心: 南京学习中心 ————————————————————————————— 第2章 【2.3】 测试下面的注释(它在C++风格的单行注释中套入了类似于C的注释)是否有效。 //this is a strange /*way to do a comment*/ 答:此注释有效,单行注释中可以嵌套 / * „„ * /方式的注释。 【2.4】 以下这个简短的C++程序不可能编译通过,为什么? #

2、include using namespace std; int main() {int a,b,c; cout<<"Enter two numbers:"; cin>>a>>b; c=sum(a,b); cout<<"sum is:"<

3、 回答问题。 (1) 以下两个函数原型是否等价: float fun(int a,float b,char *c); float fun(int,float,char * ); (2) 以下两个函数的第一行是否等价: float fun(int a,float b,char * c); float fun(int,float,char * ); 答:(1)这两个函数原型是等价的,函数原型中的参数名可以缺省。 (2)这两个函数的第1行是不等价的,因为这个函数的第1行中必须包含参数名。 【2.6】 下列语句中错误的是( D )。 A.int *p=new int(10);

4、 B.int *p=new int[10]; C.int *p=new int; D.int *p=new int[40](0); 【2.7】 假设已经有定义“const char * const name="chen";”下面的语句中正确的是( D )。 A. name[3]='a'; B. name="lin"; C. name=new char[5]; D. cout<

5、 A. name[3]='q'; B. name="lin"; C. name=new char[5]; D. name=new char('q'); 【2.9】 假设已经有定义“const char * name="chen";”下面的语句中错误的是( A )。 A. name[3]='q'; B. name="lin"; C. name=new char[5]; D. name=new char('q'); 【2.10】重载函数在调用时选择的依据中,( B )是错误的。 A.

6、函数名字 B.函数的返回类型 C.参数个数 D.参数的类型 【2.11】 在( A )情况下适宜采用内联函数。 A.函数代码小,频繁调用 B.函数代码多,频繁调用 C.函数体含有递归语句 D. 函数体含有循环语句 【2.12】 下列描述中,( C )是错误的。 A. 内联函数主要解决程序的运行效率问题 B. 内联函数的定义必须出现在内联函数第一次被调用之前 C. 内联函数中可以包括各种语句

7、 D. 对内联函数不可以进行异常接口声明 【2.13】 在C++中,关于下列设置默认参数值的描述中,( B )是正确的。 A.不允许设置默认参数值 B.在指定了默认值的参数右边,不能出现没有指定默认值的参数 C.只能在函数的定义性声明中指定参数的默认值 D. 设置默认参数值时,必须全部都设置 【2.14】 下面的类型声明中正确是( D )。 A. int &a[4]; B. int &*p; C.int &&q; D. in

8、t i,*p=&i; 【2.15】 下面有关重载函数的说法中正确的是( C )。 A.重载函数必须具有不同的返回值类型 B.重载函数形参个数必须不同 C. 重载函数必须有不同的形参列表 D.重载函数名可以不同 【2.16】 关于new运算符的下列描述中,( D )是错误的。 A,它可以用来动态创建对象和对象数组 B. 使用它创建的对象或对象数组

9、可以使用运算符delete删除 C. 使用它创建对象时要调用构造函数 D. 使用它创建对象数组时必须指定初始值 【2.17】 关于delete运算符的下列描述中,( C )是错误的。 A.它必须用于new返回的指针 B. 使用它删除对象时要调用析构函数 C. 对一个指针可以使用多次该运算符 D.指针名前只有一对方括号符号,不管所删除数组的维数 【2.18】 写

10、出下列程序的运行结果。 #include using namespace std; int i=15; int main() { int i; i=100; ::i=i+1; cout<<::i< using namespace std; void f(int &m,int n) { int temp; temp=m;

11、 m=n; n=temp; } int main() { int a=5,b=10; f(a,b); cout< using namespace std; int &f(int &i) { i+=10; return i; } int main() { int k=0; int &m=f(k); cout<

12、turn 0; } 答:10 20 【2.21】 举例说明可以使用const替代#define以消除#define的不安全性。 答:例如:#include #define A 2+4 #define B A*3 void main() { cout<

13、性。 #include const A=2+4; const B=A*3; void main() { cout< using namespace std; int main() { int * p=new int[20]; *p=1; *(p+1)=1; cout<<*p<

14、<”\t<<*(p+1)<<”\t”; p=p+2; for(int i=3;i<=20;i++) { *p=*(p-1)+*p(p-2); Cout<<*p<<”\t”; If(i%5==0)cout< #include U

15、sing namespace std; Double sroot(int i) { Return sqrt(i);} Double sroot(long l) {return sqrt(l);} Double sroot(double d) {return sqrt(d);} Int main() { Int i=12; Long l=1234; Double d=12.34; Cout<<”i的二次方根是:”<

16、l; Cout<<”d的二次方根是:”< Using namespace std; Int main() { Int I,j,sum=0; For(i=0;i<=20;i++) For(j=0;j<=50;j++) If(100-5 * I -2 * j >= 0) {

17、 Sum++; Cout<<100-5 * I – 2* j<<”\t”< Using namespace std; Int main() { void change(int &,int &); Int a,b; Cin>>a>>b;

18、 If(a>b)change(a,b); Cout<

19、 )。 A.可以在类的声明中给数据成员赋初值 B.数据成员的数据类型可以是register C.private、public、protected可以按任意顺序出现 D.没有用private、public、protected定义的数据成员是公有成员 【3.9】 在下面有关析构函数特征的描述中,正确的是( C)。 A.一个类中可以定义多个析构函数 B. 析构函数名与类名完全相同 C. 析构函数不能指定返回类型 D. 析构函数可以有一个或多个参数 【3.10】 构造函数是在( B )时

20、被执行的。 A.程序编译 B. 创建对象 C. 创建类 D.程序装人内存 【3.11】 在下面有关静态成员函数的描述中,正确的是( B )。 A.在静态成员函数中可以使用this指针 B. 在建立对象前,就可以为静态数据成员赋值 C. 静态成员函数在类外定义时,要用static前缀 D. 静态成员函数只能在类外定义 【3.12】 在下面有关友元函数的描述中,正确的说法是〔 A )。 A.友元函数是独立于

21、当前类的外部函数 B. 一个友元函数不能同时定义为两个类的友元函数 C. 友元函数必须在类的外部定义 D. 在外部定义友元函数时,必须加关键字friend 【3.13】 友元的作用之一是(A) A.提高程序的运行效率 B.加强类的封装性 C. 实现数据的隐藏性 D. 增加成员函数的种类 【3.14】 以下程序运行的结果是( B )。 #include using namespace std; class B{ public: B(){} B(

22、int i,int j) { x=i; y=j; } void printb() {cout<

23、); a.printa(); return 0; } A.8,9 B. 7,8 C. 5,6 D. 9,10 【3.15】 以下程序的运行结果是( A) #include using namespace std; class A{ public: void set(int i,int j) { x=i; y=j; } int get_y() {return y; } private: int x,y; }; class box{

24、 public: void set(int l,int w,int s,int p) { length=1; width=w; label.set(s,p); } int get_area() {return length*width; } private: int length,width; A label; }; int main() { box b; b.set(4,6,1,20); cout<

25、24 B. 4 C. 20 D. 6 【3.16】 以下程序的运行结果是( B )。 #include using namespace std; class Sample{ public: Sample(int i,int j) { x=i; y=j; } void disp() {cout<<"disp1"<

26、e: int x,y; }; int main() {const Sample a(1,2); a.disp(); return 0; } A. disp1 B.disp2 C. disp1 disp2 D. 程序编译出错 【3.17】 以下程序的运行结果是( B )。 #include using namespace std; class R{ public: R(int r1,int r2) {R1=r1; R2=r2; } void print(); void

27、print() const; private: int R1,R2; }; void R::print() {cout<

28、ude using namespace std; class toy { public: toy(int q,int p) {quan=q; price=p; } int get_quan() {return quan; } int get_price() { return price; } private: int quan,price; }; int main() { toy op[3][2]={ toy(10,20),toy(30,48), toy(50,68),toy(7

29、0,80), toy(90,16),toy(11,120), }; for(int i=0;i<3;i++) {cout<

30、面程序的运行结果。 #include using namespace std; class example { public: example(int n) { i=n; cout<<"Constructing\n"; } ~example() { cout<<"Destructing\n"; } int get_i() { return i; } private: int i; }; int sqr_it(example o) {return o.get_i()*o.get_i();

31、 } int main() { example x(10); cout< using namespace std; class aClass { public: aClass() {total++; } ~aClass

32、) {total--; } int gettotal() { return total; } private: static int total; }; int aClass::total=0; int main() {aClass o1,o2,o3; cout<

33、l(); cout<<"objects in existence after allocation\n"; delete p; cout<

34、 #include using namespace std; class test { public: test(); ~test(){}; private: int i; }; test::test() { i=25; for(int ctr=0;ctr<10;ctr++) { cout<<"Counting at"<

35、 Counting at 2 Counting at 3 Counting at 4 Counting at 5 Counting at 6 Counting at 7 Counting at 8 Counting at 9 【3.22】 写出下面程序的运行结果。 #include using namespace std; class A{ int a,b; public: A() {a=0; b=0; cout<<"Default constructor called.\n"; }

36、A(int i,int j) {a=i; b=j; cout<<"Constructor: a="<

37、Constructor:a=5,b=6 【3.23】 写出下面程序的运行结果。 #include using namespace std; class Test{ private: int val; public: Test() { cout<<"default."<

38、< using namespace std; class N{ private: int A; static int B; public: N(int a) {A=a; B+=a;

39、 } static void f1(N m); }; void N::f1(N m) {cout<<"A="<x; y=m->y; } void fun(M m1,M*m2) {m1.setxy(12,15); m2->setxy(22,25); } i

41、nt main() {M p(5,7),q; q.copy(&p); fun(p,&q); p.print(); q.print(); return 0; } 答:5,7 22,25 【3.26】 写出下面程序的运行结果。 #include using namespace std; class M{ int A; static int B; public: M(int a) {A=a; B+=a; cout<<"Constructing"<

42、tic void f1(M m); ~M() {cout<<"Destructing \n"; } }; void M::f1(M m) {cout<<"A="<

45、s; } void setAge(int a) { age=a; } int main() { Student lin; lin.setSno(20021); lin.setAge(20); lin.printStu(); } 答:这个函数是不能访问到类student中的age属性的 age不是类的成员 也不能通过lin.setage() 调用 【3.29】 指出下列程序中的错误,并说明为什么。 #include using namespace std; class Point{ public: int x,

46、y; private: Piont() {x=1;y=2; } }; int main() {Point cpoint; cpoint.x=2; return 0; } 答:构造函数不能是private属性的 必须是public的 要不然构造函数 访问不到 就不能进行申明这个实例 【3.30】 下面是一个计算器类的定义,请完成该类成员函数的实现。 class counter{ public: counter(int number); void increment(); //给原值加1 void decr

47、ement(); //给原值减1 int getvalue(); //取得计数器值 int print(); //显示计数 private: int value; }; 答: Class counter{ Public: Counter(int number); Void increment(); Void decrement(); Int getvalue(); Int print(); Private: Int value; }; Cou

48、nter::counter(int number){value=number;} Void counter::increment(){value++;} Void counter::decrement(){value--;} Int counter::getvalue(){return value;} Int counter::print() { Cout<<”value is “<

49、 } 【3.31】 根据注释语句的提示,实现类Date的成员函数。 #include using namespace std; class Date{ public: void printDate(); //显示日期 void setDay(int d); //设置日的值 void setMonth(int m); //设置月的值 void setYear(int y); //设置年的值 private: in

50、t day,month,year; }; int main() { Date testDay; testDay.setDay(5); testDay.setMonth(10); testDay.setYear(2003); testDay.printDate(); return 0; } 答:Void Date::printDate() { Cout<<”\nDate is”<

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服