欢迎来到天天文库
浏览记录
ID:25937564
大小:47.50 KB
页数:4页
时间:2018-11-23
《vc++编程练习题(xin)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、编程题(第一小题8分,第二小题11分,共19分)1、设计一个程序。定义一个圆类(circle),其中有一数据成员:半径(radius),计算圆的面积(area)和周长(perimeter),并写出主函数测试你编写的类。要求:分别用成员函数和友元函数来求圆的面积和周长。(9分)四、给出下列程序运行后的输出结果(每小题5分,共15分)1.#includevoidmain(){chara[10]="protected";charb[10]="processed"intn=0,i=0;while(a
2、[i]!=' '){if(a[i]==b[i])n++;i++;}cout<<'n='<3、ut<<”Destructingderived”;}};voidmain(){derivedob;}3、#includeintfun(int*a,intn){ints=0;for(inti=0;i4、果。(10分)#include#includeclassAbc{chara[10];int*p1,*p2;public:Abc(charaa[],int*pp1,int*pp2){strcpy(a,aa);p1=pp1;p2=pp2;cout<<"constructor..."<5、ntx1=777,y1=999,x2=222,y2=888;Abca1("ShangHai",&x1,&y1),a2("JiaoTong",&x2,&y2);//执行构造函数a1.print();a2.print();return0;//执行析构函数}写出下面程序的运行结果#includeclassA{public:A(){cout<<"<1>A::A()"<A::~A()"<6、<3>A::g()"<A::h()"<B::B()"<B::~B()"<B::g()"<B::h()"<7、;}virtualvoidk(){f();g();h();}};一、写出下面程序的运行结果 #includeclassA{public:A(){cout<<1<8、Add(intn){returna.Add(n+num);}private:A&a;intnum;};classB:publicA{public:B(intn):num(n){}virtual~B(){}virtualintAdd(intn){num+=n;returnnum;}private:intnum;};voidmain(){{Bb(100);Cc1
3、ut<<”Destructingderived”;}};voidmain(){derivedob;}3、#includeintfun(int*a,intn){ints=0;for(inti=0;i4、果。(10分)#include#includeclassAbc{chara[10];int*p1,*p2;public:Abc(charaa[],int*pp1,int*pp2){strcpy(a,aa);p1=pp1;p2=pp2;cout<<"constructor..."<5、ntx1=777,y1=999,x2=222,y2=888;Abca1("ShangHai",&x1,&y1),a2("JiaoTong",&x2,&y2);//执行构造函数a1.print();a2.print();return0;//执行析构函数}写出下面程序的运行结果#includeclassA{public:A(){cout<<"<1>A::A()"<A::~A()"<6、<3>A::g()"<A::h()"<B::B()"<B::~B()"<B::g()"<B::h()"<7、;}virtualvoidk(){f();g();h();}};一、写出下面程序的运行结果 #includeclassA{public:A(){cout<<1<8、Add(intn){returna.Add(n+num);}private:A&a;intnum;};classB:publicA{public:B(intn):num(n){}virtual~B(){}virtualintAdd(intn){num+=n;returnnum;}private:intnum;};voidmain(){{Bb(100);Cc1
4、果。(10分)#include#includeclassAbc{chara[10];int*p1,*p2;public:Abc(charaa[],int*pp1,int*pp2){strcpy(a,aa);p1=pp1;p2=pp2;cout<<"constructor..."<5、ntx1=777,y1=999,x2=222,y2=888;Abca1("ShangHai",&x1,&y1),a2("JiaoTong",&x2,&y2);//执行构造函数a1.print();a2.print();return0;//执行析构函数}写出下面程序的运行结果#includeclassA{public:A(){cout<<"<1>A::A()"<A::~A()"<6、<3>A::g()"<A::h()"<B::B()"<B::~B()"<B::g()"<B::h()"<7、;}virtualvoidk(){f();g();h();}};一、写出下面程序的运行结果 #includeclassA{public:A(){cout<<1<8、Add(intn){returna.Add(n+num);}private:A&a;intnum;};classB:publicA{public:B(intn):num(n){}virtual~B(){}virtualintAdd(intn){num+=n;returnnum;}private:intnum;};voidmain(){{Bb(100);Cc1
5、ntx1=777,y1=999,x2=222,y2=888;Abca1("ShangHai",&x1,&y1),a2("JiaoTong",&x2,&y2);//执行构造函数a1.print();a2.print();return0;//执行析构函数}写出下面程序的运行结果#includeclassA{public:A(){cout<<"<1>A::A()"<A::~A()"<6、<3>A::g()"<A::h()"<B::B()"<B::~B()"<B::g()"<B::h()"<7、;}virtualvoidk(){f();g();h();}};一、写出下面程序的运行结果 #includeclassA{public:A(){cout<<1<8、Add(intn){returna.Add(n+num);}private:A&a;intnum;};classB:publicA{public:B(intn):num(n){}virtual~B(){}virtualintAdd(intn){num+=n;returnnum;}private:intnum;};voidmain(){{Bb(100);Cc1
6、<3>A::g()"<A::h()"<B::B()"<B::~B()"<B::g()"<B::h()"<7、;}virtualvoidk(){f();g();h();}};一、写出下面程序的运行结果 #includeclassA{public:A(){cout<<1<8、Add(intn){returna.Add(n+num);}private:A&a;intnum;};classB:publicA{public:B(intn):num(n){}virtual~B(){}virtualintAdd(intn){num+=n;returnnum;}private:intnum;};voidmain(){{Bb(100);Cc1
7、;}virtualvoidk(){f();g();h();}};一、写出下面程序的运行结果 #includeclassA{public:A(){cout<<1<8、Add(intn){returna.Add(n+num);}private:A&a;intnum;};classB:publicA{public:B(intn):num(n){}virtual~B(){}virtualintAdd(intn){num+=n;returnnum;}private:intnum;};voidmain(){{Bb(100);Cc1
8、Add(intn){returna.Add(n+num);}private:A&a;intnum;};classB:publicA{public:B(intn):num(n){}virtual~B(){}virtualintAdd(intn){num+=n;returnnum;}private:intnum;};voidmain(){{Bb(100);Cc1
此文档下载收益归作者所有