欢迎来到天天文库
浏览记录
ID:40522389
大小:40.00 KB
页数:7页
时间:2019-08-04
《c++综合复习1参考答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、分析下面程序运行结果1)#includeclassB{public:B(){}B(inti,intj){a=i;b=j;}voidprintb(){cout<<"a="<classCSample{
2、inti;public:CSample();voiddisp();~CSample();};CSample::CSample(){cout<<"Constructor"<<",";i=0;}voidCSample::disp(){cout<<"i="<classA{public:A(in
3、ti,intj){a=i;b=j;}voidmove(intx,inty){a+=x;b+=y;}voidshow(){cout<<"("<4、);e.show();Bd(3,4,5,6);d.fun();d.f1();d.B::show();}输出结果:(1,2)(6,9)5,64)#includeclassA{public:A(){}virtualvoidfun1(){cout<<"Afun1"<5、oidfun1(){cout<<"Bfun1"<fun1();P->fun2();P->fun3();P->fun4();}输出结果:Bfun1Bfun2Afun3Afun45)#includeclassSample{public:intn;staticintm;Sa6、mple(inti){n=i;m+=i;}};intSample::m=1;voidmain(){Samples1(2),s2(4),s3(6);cout<<“s1.n=”<7、3.n=6,s3.m=13Sample::m=13
4、);e.show();Bd(3,4,5,6);d.fun();d.f1();d.B::show();}输出结果:(1,2)(6,9)5,64)#includeclassA{public:A(){}virtualvoidfun1(){cout<<"Afun1"<5、oidfun1(){cout<<"Bfun1"<fun1();P->fun2();P->fun3();P->fun4();}输出结果:Bfun1Bfun2Afun3Afun45)#includeclassSample{public:intn;staticintm;Sa6、mple(inti){n=i;m+=i;}};intSample::m=1;voidmain(){Samples1(2),s2(4),s3(6);cout<<“s1.n=”<7、3.n=6,s3.m=13Sample::m=13
5、oidfun1(){cout<<"Bfun1"<fun1();P->fun2();P->fun3();P->fun4();}输出结果:Bfun1Bfun2Afun3Afun45)#includeclassSample{public:intn;staticintm;Sa
6、mple(inti){n=i;m+=i;}};intSample::m=1;voidmain(){Samples1(2),s2(4),s3(6);cout<<“s1.n=”<7、3.n=6,s3.m=13Sample::m=13
7、3.n=6,s3.m=13Sample::m=13
此文档下载收益归作者所有