首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
2021-05-06
23
问题
有如下程序:
#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://kaotiyun.com/show/wPfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下类定义和对象定义:classA{public:A():data(0){}A(intx):data(x){}~A(){}intGetData()const{return
有如下类声明:classTe{public:Te();//①Tete;//②Te*
有如下程序:#includeusingnamespacestd;classA{public:staticinta;voidinit(){a=1;}A(inta=2){ini
请编写一个函数intfun(int*s,intt,int*k),用来求出数组的最大元素在数组中的下标并存放在k所指向的存储单元中。例如,输入如下整数:876675896101301401980431451777则输出
随机试题
ACD保养液保存血液的有效天数是
A.鼻泪管不全阻塞或狭窄B.泪总管阻塞C.鼻泪管阻塞合并慢性泪囊炎D.泪小管阻塞E.功能性泪溢
导致阻塞性肺气肿和慢性肺源性心脏病占第一位的病因是
患者临床诊断最大可能是其治疗方法目前首选
A.不小于150平方米B.不小于100平方米C.不小于50平方米D.不小于40平方米E.不小于30平方米大型零售企业营业场所的面积()
预算必须与企业的战略或目标保持一致,这是预算最主要的特征。()
本题涉及增值税法、税收征收管理法。大华机械公司为增值税一般纳税人,主要生产各种电动工具。2014年7月10日该公司申报缴纳6月份增值税税款100万元。7月底,税务机关对该公司6月份增值税计算缴纳情况进行专项检查,有关检查情况如下:(1)6月2日收到代销
下列控制活动中,属于检查性控制的有()。
正方体ABCD-A’B’C’D’中,侧面对角线AC与BC’所成的角等于()。
Futurologistshavenotbeenverypreciseabouthowandhowmuchdigitalmediawillchangeourlives.Mostofcommentshavefocus
最新回复
(
0
)