欢迎来到天天文库
浏览记录
ID:59307813
大小:407.50 KB
页数:25页
时间:2020-09-05
《C++第六次作业培训资料.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一、【3.14】1、题目:以下程序的运行结果是(B.7,8)#includeusingnamespacestd;classB{public:B(){}B(inti,intj){x=i;y=j;}voidprintb(){cout<2、();return0;}1、运行结果:【3.15】1、题目:以下程序的运行结果是(A.24)#includeusingnamespacestd;classA{public:voidset(inti,intj){x=i;y=j;}intget_y(){returny;}private:intx,y;};classbox{public:voidset(intl,intw,ints,intp){length=l;width=w;label.set(s,p);}intget_area(){returnlength*width;}private:intlength,width3、;Alabel;};intmain(){boxb;b.set(4,6,1,20);cout<usingnamespacestd;classSample{public:Sample(inti,intj){x=i;y=j;}voiddisp(){cout<<"displ"<4、amplea(1,2);a.disp();return0;}2、运行结果。【3.17】1、题目:以下程序的运行结果是(B.56,88)#includeusingnamespacestd;classR{public:R(intr1,intr2){R1=r1;R2=r2;}voidprint();voidprint()const;private:intR1,R2;};voidR::print(){cout<5、constRb(56,88);b.print();return0;}2、运行结果。【3.18】1、题目:写出下面程序的运行结果。#includeusingnamespacestd;classtoy{public:toy(intq,intp){quan=q;price=p;}intget_quan(){returnquan;}intget_price(){returnprice;}private:intquan,price;};intmain(){toyop[3][2]={toy(10,20),toy(30,48),toy(50,68),toy(70,80),toy(6、90,16),toy(11,120),};for(inti=0;i<3;i++){cout<usingnamespacestd;classexample{public:example(intn){i=n;co7、ut<<"Constructing";}~example(){cout<<"Destructing";}intget_i(){returni;}private:inti;};intsqr_it(exampleo){returno.get_i()*o.get_i();}intmain(){examplex(10);cout<
2、();return0;}1、运行结果:【3.15】1、题目:以下程序的运行结果是(A.24)#includeusingnamespacestd;classA{public:voidset(inti,intj){x=i;y=j;}intget_y(){returny;}private:intx,y;};classbox{public:voidset(intl,intw,ints,intp){length=l;width=w;label.set(s,p);}intget_area(){returnlength*width;}private:intlength,width
3、;Alabel;};intmain(){boxb;b.set(4,6,1,20);cout<usingnamespacestd;classSample{public:Sample(inti,intj){x=i;y=j;}voiddisp(){cout<<"displ"<4、amplea(1,2);a.disp();return0;}2、运行结果。【3.17】1、题目:以下程序的运行结果是(B.56,88)#includeusingnamespacestd;classR{public:R(intr1,intr2){R1=r1;R2=r2;}voidprint();voidprint()const;private:intR1,R2;};voidR::print(){cout<5、constRb(56,88);b.print();return0;}2、运行结果。【3.18】1、题目:写出下面程序的运行结果。#includeusingnamespacestd;classtoy{public:toy(intq,intp){quan=q;price=p;}intget_quan(){returnquan;}intget_price(){returnprice;}private:intquan,price;};intmain(){toyop[3][2]={toy(10,20),toy(30,48),toy(50,68),toy(70,80),toy(6、90,16),toy(11,120),};for(inti=0;i<3;i++){cout<usingnamespacestd;classexample{public:example(intn){i=n;co7、ut<<"Constructing";}~example(){cout<<"Destructing";}intget_i(){returni;}private:inti;};intsqr_it(exampleo){returno.get_i()*o.get_i();}intmain(){examplex(10);cout<
4、amplea(1,2);a.disp();return0;}2、运行结果。【3.17】1、题目:以下程序的运行结果是(B.56,88)#includeusingnamespacestd;classR{public:R(intr1,intr2){R1=r1;R2=r2;}voidprint();voidprint()const;private:intR1,R2;};voidR::print(){cout<5、constRb(56,88);b.print();return0;}2、运行结果。【3.18】1、题目:写出下面程序的运行结果。#includeusingnamespacestd;classtoy{public:toy(intq,intp){quan=q;price=p;}intget_quan(){returnquan;}intget_price(){returnprice;}private:intquan,price;};intmain(){toyop[3][2]={toy(10,20),toy(30,48),toy(50,68),toy(70,80),toy(6、90,16),toy(11,120),};for(inti=0;i<3;i++){cout<usingnamespacestd;classexample{public:example(intn){i=n;co7、ut<<"Constructing";}~example(){cout<<"Destructing";}intget_i(){returni;}private:inti;};intsqr_it(exampleo){returno.get_i()*o.get_i();}intmain(){examplex(10);cout<
5、constRb(56,88);b.print();return0;}2、运行结果。【3.18】1、题目:写出下面程序的运行结果。#includeusingnamespacestd;classtoy{public:toy(intq,intp){quan=q;price=p;}intget_quan(){returnquan;}intget_price(){returnprice;}private:intquan,price;};intmain(){toyop[3][2]={toy(10,20),toy(30,48),toy(50,68),toy(70,80),toy(
6、90,16),toy(11,120),};for(inti=0;i<3;i++){cout<usingnamespacestd;classexample{public:example(intn){i=n;co
7、ut<<"Constructing";}~example(){cout<<"Destructing";}intget_i(){returni;}private:inti;};intsqr_it(exampleo){returno.get_i()*o.get_i();}intmain(){examplex(10);cout<
此文档下载收益归作者所有