首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果是【 】。 #include <iostream> using namespace std; class base { public: int n; base(int x) { n=x;}
下列程序的输出结果是【 】。 #include <iostream> using namespace std; class base { public: int n; base(int x) { n=x;}
admin
2009-01-15
30
问题
下列程序的输出结果是【 】。
#include <iostream>
using namespace std;
class base {
public:
int n;
base(int x) { n=x;}
virtual void set(int m) { n=m; cout<<n<<’ ’;}
};
class deriveA :public base {
public:
deriveA(int x):base(x) {}
void set(int m) { n+=m; cout<<n<<’ ’;}
};
class derive B: public base {
public:
derive B(int x):base(x) {}
void set(int m) { n+=m; cout<<n<<’ ’;}
};
int main()
{
derive A, d1(1);
derive B, d2(3);
base *pbase;
pbase=&d1;
pbase->set(1);
pbase=&d2;
phase->set(2);
return 0;
}
选项
答案
25
解析
转载请注明原文地址:https://kaotiyun.com/show/iVkp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序:#includevoidmain(){FILE*pf;char*sl=’’Mystring’’,*s2=’’Text’’;pf=fopen(’’f.dat’’,’’wb+’’);fwrite(sl,8,1,pf);rewind(
在一棵二叉树上,第5层的结点数最多是()。
以下不是合法C语言转义字符的是
逻辑模型是面向数据库系统的模型,下面属于逻辑模型的是
设fp为指向某二进制文件的指针,且已读到此文件末尾,则函数feof(fp)的返回值为()。
以下关于逻辑运算符两侧运算对象的叙述中正确的是
算法的空间复杂度是指()。
给定程序中,函数fun的功能是:统计出带有头结点的单向链表中结点的个数,存放在形参n所指的存储单元中。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。注意:源程序存放在考生文件夹下的BLANK1.C中。不
软件调试的目的是()。
在公有派生的情况下,派生类中定义的成员函数只能访问原基类的
随机试题
ItisnotthatIdonotlikeplays.ThereasonwhyIdidnotgotothetheaterlastnightwasthatIcouldnot______thetime.
A.协同凝集试验B.正向间接血凝试验C.反向间接血凝试验D.正向间接血凝抑制试验E.反向间接血凝抑制试验用红细胞包被抗体检测抗原的是
在减少与抑制散射线的方法中,错误的是
A.混悬剂B.散剂C.气雾剂D.乳膏剂E.洗剂固体剂型是
肛管手术后不允许灌肠的时间为
财务成本人员的成本管理责任包括( )。
A、2001B、2030C、3010D、无法确定D
England’sbinge-drinkinghabitisoneofthemostentrenchedinEurope—evenRomaninvaderswroteaboutitwithhorror.Manyfear
Peoplejudgethesedeviationsfromthenormaspositivebecausetheysuggestthattheindividualispowerfulenoughtoriskthe
AnumberofscientificstudieshavefoundthattheamountofsugarweconsumeisamajorfactorinhowbigAmericanshavebecome
最新回复
(
0
)