首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Instrument { public: virtual void Display()=0; }; class Piano : public Instrument {
有如下程序: #include using namespace std; class Instrument { public: virtual void Display()=0; }; class Piano : public Instrument {
admin
2020-06-29
29
问题
有如下程序:
#include
using namespace std;
class Instrument {
public:
virtual void Display()=0;
};
class Piano : public Instrument {
public:
void Display() { /*函数体略*/ }
};
int main() {
Instrument s;
Instrument *p=0;
//… ;
return 0;
}
下列叙述中正确的是( )。
选项
A、语句"Insturment *p=0;"编译时出错
B、语句"Instrument s;"编译时出错
C、类Piano中的Display函数不是虚函数
D、类Instrument是一个虚基类
答案
B
解析
本题考查纯虚函数和抽象类,纯虚函数是在声明虚函数时被"初始化"为0的函数,包含纯虚函数的类为抽象类,抽象类不能被实例化,所以语句"Instrument s;"在编译时出错。
转载请注明原文地址:https://jikaoti.com/ti/cvl0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。完成函数ToUpper(char木des,char*str),该函数实现把str字符串中小写字符转换成大写字符,并存发在des中。例如:str=“aBc
使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)定义CMyTime的私有成员函数myear、mmonth类型为int,请在注释∥********1*****
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,即使程序在界面输出以下类似内容:0012FF6810012FF3C50012FF6C20012FF444
耦合性和内聚性是对模块独立性度量的两个标准。下列叙述中正确的是( )。
下列关于函数参数的叙述中,正确的是
在定义一个类模板时,模板形参表是用一对括号括起来的,所采用的括号是
下列选项中,不是C++关键字的是
下列选项中,正确的C++表达式是
数据库中对概念模式内容进行说明的语言是
随机试题
资源利用的优化主要包括()。
NaturalFoodsIncreasingly,overthepasttenyears,peopleespeciallyyoungpeoplehavebecomeawareoftheneedtochanget
不稳定性纤维蛋白在哪项的作用下,形成稳定性交联纤维蛋白TF与FⅦ或FⅦA在哪项存在的条件下,形成TF/FⅦ或TF/FⅦA复合物
A.AFPB.CEAC.CAl25D.CA15-3E.PSA肝癌常用的肿瘤标记物为
对于水泥混凝土及水泥砂浆面层,下列说法正确的是:()
客户在(),应将咨询合同草案发给工程咨询公司。
人民法院裁定受理破产申请的,指定管理人的时间应为()。
规定农产品的价格、数量和质量,并规定生产者按照加工销售商制定的生产方案进行生产,这属于农业产业化经营合同制模式中的()合同。
EIQ规划法是指针对不确定和波动条件,根据设置目的,掌握物流特性和物流状态,规划出符合实际的企业配送中心系统的一种方法。()
我怎么能为他的讲话负责呢?
最新回复
(
0
)