首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
如下程序执行后的输出结果是【 】。 #include <iostream> using namespace std; class Base { public: Base(int x,int y)
如下程序执行后的输出结果是【 】。 #include <iostream> using namespace std; class Base { public: Base(int x,int y)
admin
2013-02-27
41
问题
如下程序执行后的输出结果是【 】。
#include <iostream>
using namespace std;
class Base
{
public:
Base(int x,int y)
{
a=x;
b=y;
}
void Show()
{
cout<<"Base: "<<a<< ’,’ <<b<<" ";
}
private:
int a,b;
};
class Derived : public Base
{
public:
Derived(int x, int y, int z) : Base(x,y),c(z) { }
void Show()
{
cout<<"Derived:"<<c<<end1;
}
private:
int c;
};
int main()
{
Base b(100,100),*pb;
Derived d(10,20,30);
pb=&b;
pb->Show();
pb=&d;
pb->Show();
return 0;
}
选项
答案
Base:100,100 Base:10,20
解析
本题考核对象指针的应用。主函数中通过对象指针pb.分别调用其类成员函数Show()和派生类成员函数Show()先后输出 Base:100,100Base:10,20。
转载请注明原文地址:https://jikaoti.com/ti/6rE0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
关于友元,下列说法错误的是
关于内联函数的说法,不正确的是()。
对于派生类的构造函数,在定义对象时构造函数的执行顺序为:先执行【】。再执行成员对象的构造函数,后执行派生类本身的构造函数。
有关类和对象的说法不正确的是______。
在下向程序和横线处填上适当的内容,使程序执行后的输出结果为1/2005。#include<iostream>usingnamespacestd;classDate{public:Date(intm=
以下函数声明中,存在语法错误的是______。
在数据管理技术发展过程中,文件系统与数据库系统的主要区别是数据库系统具有()。
一棵二叉树第六层(根结点为第一层)的结点数最多为【】。
下面选项中,不属于C++语句的是()。
线性表L=(a1,a2,a3,…,ai,…,an),下列说法正确的是()。
随机试题
A、 B、 C、 D、 C
A.在流通空气中或阳光下30分钟失活B.不耐酸和热,对乙醚敏感C.在室温中2~3天失去传染性D.在食物和食具上可生活1~2周E.在痰和渗出物中可存活数周腮腺炎病毒
26岁女性患者,孕36周,尿频、尿急、尿痛3天,伴阴道分泌物增多。查体:尿道口及宫颈口红肿、充血,可见大量脓性分泌物。下列哪项治疗正确
治疗汗证肺卫不固的首选方剂为( )。
以下所列乳痈的成因中,哪一项是错误的
个人独资企业的特征是()。
在使用冲天炉熔炼铸铁的过程中,( )是熔化过程中要解决的重要问题之一。
干扰说可以解释学生在记忆材料中间部分较为困难的现象。()
ThewholeoftheUnitedStatescheereditslatesthero,AshleySmith,withtheFederalBureauofInvestigationsayingitwaspla
A、Toholdareceptionparty.B、Tohaveabigdinner.C、Tocongratulateonthecouple.D、Toshowerthecouplewithrice.D细节题。文章的
最新回复
(
0
)