阅读以下说明,以及用C++在开发过程中所编写的程序代码,将应填入(n)处的字句写在对应栏内。
【说明】
在下面程序横线处填上适当的字句,3个(2)空填的是一样的。使其输出结果为:
x=5
x=6
y=7
x=8
z=9
【程序】
#include<iostream.h>
class X1{
int x;
(1);
X1(int xx=0){x=xx;}
(2) void Output(){
cout<<"x="<<x<<end;
}
};
(3) Y1:public X1{
int y;
public:
Y1(int xx=0,int yy=0);X1(xx){y=yy;}
(2) void Output(){
(4) Output();
cout<<"y="<<y<<endl;
}
};
class Z1:public X1{
int z:
(5);
Z1(int xx=0,int zz=0):X1(xx)(z=zz;}
(2) void Output(){
X1∷Output();
cout<<"z="<<z<<endl;
}
};
void main()
{
X1 a(5);Y1 b(6,7);Z1 c(8,9);
X1*p[3]={&a,&b,&c);
For(int i=0;i<3;i++){
p[i]->Output();cout<<endl;
}
}
订单号:
遇到问题请联系在线客服
订单号:
遇到问题请联系在线客服