题目内容:
有如下程序: #include<iostream>
usingnamespacestd;
classB{
public:
B(intxx):x(xx){++count;x+=10;}
virtualvoidshow( )const
{cout<<count<<''<<x<<endl;}
protected:
staticintcount;
private:
intx;
};
classD:publicB{
public:
D(intxx,intyy):B(XX),y(yy){++count;y+=
100;)
virtualvoidshow( )const
{cout<<count<<''<<y<<endl);
private:
inty;
};
intB::count==0;
intmain( ){
B*ptr=newD(10,20);
ptr->show( );
deleteptr;
return0;
}
运行时的输出结果是( )。 A.1_120
B.2_120
C.1_20
D.2_20
参考答案:
答案解析: