A.B(int p1, int p2, int p3, int p4) { a = p4; }
B.B(int p1, int p2, int p3, int p4) : A(p1, p2, p3) { a = p4; }
C.B(int p1, int p2, int p3, int p4) { x = p1; y = p2; z = p3; a = p4; }
D.B(int p1, int p2, int p3, int p4) { A(p1, p2, p3); a = p4; }
第1题
A、B(int p1, int p2, int p3, int p4) { x = p1; y = p2; z = p3; a = p4; }
B、B(int p1, int p2, int p3, int p4) { A(p1, p2, p3); a = p4; }
C、B(int p1, int p2, int p3, int p4) { a = p4; }
D、B(int p1, int p2, int p3, int p4) : A(p1, p2, p3) { a = p4; }
第2题
classA{
privateintx=1;
protectedinty=2;
publicintz=3;
publicintsumA(){return(x+y+z);
}
}
再通过继承与扩展定义子类B:
classBextendsA{
privateintb=4;
publicintsumB(){
ints=0;
s+=x;s+=y;s+=z;s+=b;
returns;
}
}
方法成员sumB()中错误的语句是()。
A、s+=x;
B、s+=y;
C、s+=z;
D、s+=b;
第3题
A、m1
B、m2
C、m3
D、fun
第4题
A.Errorsatlines7and8causecompilationtofail.
B.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameonthesameline(forexample,“x=2,y=1”).
C.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby“x=1,y=1”).
D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(forexample,“x=1,y=1”.Inaddition,eachvalueappearsonlyforonce(forexample,“x=1,y=1”followedby“x=2,y=2”).
第5题
A.ConstOver(){}
B.protectedintConstOver(){}
C.privateConstOver(intz,inty,bytex){}
D.publicObjectConstOver(Intx,inty,intz){}
E.pubicvoidConstOver(bytex,bytey,bytez){}
第6题
classXX{
intxdata;
public:
XX(intn=0):xdata(n){}
};
classYY:publicXX{
intydata;
public:
YY(intm=0,intn=O):XX(m),ydata(n){}
};
YY类的对象包含的数据成员的个数是( )。
A.1
B.2
C.3
D.4
第7题
第8题
include<iostream>
using namespace std;
class A{
public:
static int x;
A(inty){cout<<x+y;}
};
int A::x=2;
void main(){
A a(5);
}
第9题
下列程序运行结果是 。 class CShape { private: int x,y; public: CShape(int xx,int yy){x=xx;y=yy;} virtual double Area(){return 0;} }; class CCircle:public CShape { private: int r; public: CCircle(int xx,int yy,int rr):CShape(xx,yy){r=rr;} virtual double Area(){return 3.14*r*r;} }; void f1(CShape &sp) { cout< <sp.area()> < <endl; } void f2(cshape sp) { main() ccircle c(10,10,1); f1(c); f2(c);>
第10题
A、该程序有错
B、该程序无错
C、本题只有AB两个选项,无需选此项
D、本题只有AB两个选项,无需选此项
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!