问题 填空题

下列程序的输出结果是______。
#include<iostream.h>
class base

int x,y;
public:
base(int i,int j)x=i;y=j;
virtual int add( )return x+y;
;
class three:public base

int z;
public:
three(int i,int j,int k):base(i,j)z=k;)
int add( )return(base::add( )+z);
;
void main( )

three*q=new three(10,20,30);
cout<<q->add( )<<endl;

答案

参考答案:60

解析: 本题考察继承中子类对父类的继承方式,注意子类的add成员函数,它直接使用了父类的成员函数进行运算。

单项选择题
单项选择题