欢迎来到天天文库
浏览记录
ID:18652275
大小:124.00 KB
页数:16页
时间:2018-09-20
《面向对象程序设计c++双语》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、12、Forstaticmemberdata,itisinitializedat(b).A.BeforethedeclarationofclassandafterthemainfunctionB.BeforethemainfunctionandafterthedeclarationofclassC.IntheclassD.Inthemainfunction二、Judgment,ifitisrightplease√otherwise×.(Everyquestionis2point,totalis18point)1、C++isasub-setofC,itreservesalmostallth
2、echaracteristicsofC.----------2、Giveninta;int&b=a;a=10;b=20;ifcout<3、accessthemembersinclassA,viceversa.-----------6、Foranon-memberoperatoroverloadingfunction,amodecomputationcandedefinedas:Xoperator%(X),whereXisthenameofaclass.------------7、Noobjectsofanabstractbaseclasscanbeinstantiated.-------------8、GivenclassB{intx;/*…..*/};wecandefineclassD:publicB{intz;publ4、ic:voidSetXZ(inta,intc){x=a;z=c;}intSun(){returnx+z;}};------------9、Objectofabaseclasscanbetreatedasanobjectofthederivedclass.------------三、Completetheprogram(3*5’=15’)(Everyquestionis5point,totalis15point)(attention:onelineforjustonesentence)1、Afterthemainfunction,theresultis:x=0;y=0x=3;y=5x=3;5、y=5Destructoriscalled...Destructoriscalled...Destructoriscalled...Pleasecompletetheprogram.#includevoidmain(){demod;d.show();demod1(3,5);d1.show();demod2(d1);d2.show();}classdemo{intx,y;public:------demo(intx=0,inty=0)-----{x=a;y=b;}---------demo(*d)-------{x=d.x;y=d.y;第16页共16页}------6、~demo()--------{-----Destructoriscalled...-----}voidshow(){-------------cout<<”x=”<#includeclassperson{char*Name;intAge;public:person(char*name,intage);~person();char*GetName(){returnName;}intGetAge(){returnAge;}voidshow();};person::p7、erson(char*name,intage){------------①-------------------------------------②-----------------------Age=age;}person::~person(){deleteName;}voidperson::show(){cout<
3、accessthemembersinclassA,viceversa.-----------6、Foranon-memberoperatoroverloadingfunction,amodecomputationcandedefinedas:Xoperator%(X),whereXisthenameofaclass.------------7、Noobjectsofanabstractbaseclasscanbeinstantiated.-------------8、GivenclassB{intx;/*…..*/};wecandefineclassD:publicB{intz;publ
4、ic:voidSetXZ(inta,intc){x=a;z=c;}intSun(){returnx+z;}};------------9、Objectofabaseclasscanbetreatedasanobjectofthederivedclass.------------三、Completetheprogram(3*5’=15’)(Everyquestionis5point,totalis15point)(attention:onelineforjustonesentence)1、Afterthemainfunction,theresultis:x=0;y=0x=3;y=5x=3;
5、y=5Destructoriscalled...Destructoriscalled...Destructoriscalled...Pleasecompletetheprogram.#includevoidmain(){demod;d.show();demod1(3,5);d1.show();demod2(d1);d2.show();}classdemo{intx,y;public:------demo(intx=0,inty=0)-----{x=a;y=b;}---------demo(*d)-------{x=d.x;y=d.y;第16页共16页}------
6、~demo()--------{-----Destructoriscalled...-----}voidshow(){-------------cout<<”x=”<#includeclassperson{char*Name;intAge;public:person(char*name,intage);~person();char*GetName(){returnName;}intGetAge(){returnAge;}voidshow();};person::p
7、erson(char*name,intage){------------①-------------------------------------②-----------------------Age=age;}person::~person(){deleteName;}voidperson::show(){cout<
此文档下载收益归作者所有