首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
若有以下程序: #include <iostream> using namespace std; class Base { public: void who() { cout<<"cl
若有以下程序: #include <iostream> using namespace std; class Base { public: void who() { cout<<"cl
admin
2013-05-30
53
问题
若有以下程序:
#include <iostream>
using namespace std;
class Base
{
public:
void who()
{
cout<<"class Base"<<end1;
}
};
class Derivedl : public Base
{
public:
void who()
{
cout<<"class Derivedl"<<end1;
}
};
class Derived2 : public Base
{
public:
void who()
{
cout<<"class Derived2"<<end1;
}
};
int main()
{
Base *p;
Derivedl obj1;
Derived2 obi2;
p=&obj 1;
p=&obj2;
p->who ( );
return 0;
}
则该程序运行后的输出结果是【 】。
选项
答案
class Derived2
解析
本题考核对象指针的应用。主函数中定义了一个Base类对象指针p,然后逐步被赋值为obj1和obj2,最后通过对象指针p调用函数who(),也即调用Derived2中的函数who(),输出class Derived2。
转载请注明原文地址:https://kaotiyun.com/show/qhNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下程序段的输出结果是()。intx=5;do{cout<<x--<<end1;}while(!x);
关于swish语句的说明中,错误的是()。
从数据库存的整体结构看,数据库存系统采用的数据模型有()。
若有下列说明:inta[12]={1,2,3,4,5,6,7,8,9,10,11,12};charc=’a’,d,g;则数值为4的表达式是______。
下面关于对象概念的描述中,()是错误的。
Jackson方法是一种面向【】的结构化方法。
下列关于对象的描述,不正确的是()。
下列对于软件测试的描述,正确的是()。
深度为k的二叉树至多有______。
随机试题
子宫内膜癌首选的治疗方法是()
临床用于治疗消化性溃疡,属于奥美拉唑(–)–(S)–异构体的药物是()。
以下做法不符合相关法律规定的是()
下列倒装句中属于定语后置的一项是()。
在教学中,通过学生观察所学事物或教师语言的形象描述,引导学生形成所学事物、过程的清晰表象,丰富他们的感性认识,从而使他们能够正确地理解书本知识和发展认知能力。这体现的教学原则是()
在CPU中,常用来为ALU执行算术逻辑运算提供数据并暂存运算结果的寄存器是_______。
Awebcamisadigitalcamerathatsendsvideoimagestoothercomputerusers.It’saboutthe【C1】______ofagolfballandtyp
Theoriginsofbottledwatercanbe【B1】______backtotheearliest【B2】______.Wellawareofwater’shealthfacts,theRomansse
Theproblemofhowhealth-careresourcesshouldbeallocatedorapportioned,sothattheyaredistributedinboththemostjust
CanTonyBlairSavetheWorldofBooks?[A]AtthebeginningofAJourney,TonyBlairboaststhathehas"thesoulofarebel".
最新回复
(
0
)