首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果是______。 #include<iostream.h> class base { int x,y; public: base(int i,int j){x=i;y=j;}
下列程序的输出结果是______。 #include<iostream.h> class base { int x,y; public: base(int i,int j){x=i;y=j;}
admin
2013-02-27
18
问题
下列程序的输出结果是______。
#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成员函数,它直接使用了父类的成员函数进行运算。
转载请注明原文地址:https://kaotiyun.com/show/szNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
已知字符A的ASCII码值是65,字符变量c1的值是’A’,c2的值是’D’,则执行语句printf("%d,%d",c1,c2-2);的输出结果是()。
有下列程序 #include<stdio.h> #include<string.h> main() {charv[4][10]={"efg","abcd","mnopq","hijkl"},*p[4],*t; inti,j; f
有以下程序 #include<stdio.h> main() {inta[3][3]={{1,3,5,}, {7,9,11,}, {13,15,17}}; int(*p)[3]=a,i,j,n=0; fo
有以下程序 #include<stdio.h> typedefstruct{intnum;charname[10];intscore;}PER; voidfun(PERx[]) {intt; if(x[0].score>x
下列叙述中正确的是()。
顺序存储方法是把逻辑上相邻的结点存储在物理位置【】的存储单元中。
对于下面程序,选项正确的是()。#include<iostream>usingnamespacestd;classpoint{public:voidsetpoint(un
己知类Myst有一个只需要一个double型参数的构造函数,且将运算符“-”重载为友元函数。要使语句序列Mystx(3.2),y(5.5),z(0.0);z=8.9-y;y=x-6.3;能够正常运行,运算符函数oper
已知程序中已经定义了函数test,其原型是inttest(int,int,int);,则下列重载形式中正确的是()。
随机试题
把一个电阻为30Q、电感为127mH的线圈接到电压为(314t+30°)V的电源上,求其感抗、阻抗、阻抗角、电流及电流瞬时值表达式、功率因数、有功功率。
电子商务的技术要素组成中,首先要有(),其次必须有各种各样的(),当然也少不了以各种服务器为核心组成的计算机系统。
社会主义的荣辱观体现了社会主义道德建设的客观要求()
下列关于心身疾病的条件说法不正确的是
葡萄胎处理原则,哪项不妥
消防设施的设备及其组件、材料等产品质量检查主要包括外观检查、组件装配及其结构检查、基本功能试验以及灭火剂质量检测等内容。其中()需按照规定对灭火剂进行抽样检测。
有限责任公司的注册资本为在公司登记机关登记的全体股东认缴的()。
8岁的李林,尽管他的协调能力很差,但从表面看是一个喜欢运动、非常快乐的孩子,然而他干什么都是三分钟热度,上课总走神,学习成绩差,对于家长和老师的话充耳不闻,讨厌学习,在活动中表现霸道,几乎每天都被老师批评,许多孩子也不愿意和他一起玩。韦克斯勒儿童智力测试的
蒙古、色目人犯奸盗诈伪案件,其管辖机构是()。
A、Whichdiplomaheshouldworkfor.B、Howthediplomacourseisconducted.C、Howmanysubjectsthediplomacourseincludes.D、Ho
最新回复
(
0
)