首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Base { private: void fun1() const { cout
有如下程序: #include using namespace std; class Base { private: void fun1() const { cout
admin
2015-07-22
45
问题
有如下程序:
#include
using namespace std;
class Base
{
private:
void fun1() const { cout<<"fun1"; }
protected:
void fun2() const { cout<<"fun2"; }
public:
void fun3() const { cout<<"fun3"; }
};
class Derived : protected Base
{
public:
void fun4() const { cout<<"fun4"; }
};
int main()
{
Derived obj;
obj.fun1(); // ①
obj.fun2(); // ②
obj.fun3(); // ③
obj.fun4(); // ④
return 0;
}
其中有语法错误的语句是( )。
选项
A、①②③④
B、①②③
C、②③④
D、①④
答案
B
解析
本题考查保护继承中派生类对基类的访问属性,受保护继承中,基类的公用成员和保护成员在派生类中成了保护成员,其私有成员仍为基类私有,保护基类的所有成员在派生类中都被保护起来,在类外不能访问,所以①②③错误。
转载请注明原文地址:https://kaotiyun.com/show/W5Np777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
设有如下三个关系表下列操作中正确的是
下列选项中不符合良好程序设计风格的是
有如下程序:#include<iostream>usingnamespacestd;classDA{intk;public:DA(intx=1):k(x){}~DA(){cout<<k;}};intmain(
有如下定义:classMA{intvalue;public:MA(intn=0):value(n){}};MA*ta,tb;其中MA类的对象名标识符是【】。
有如下程序: #include<iostream> using namespace std; class A { public: A(int i) {x=i;} void dispa() {cout<<x
在结构化程序设计中,模块划分的原则是
有如下程序:#include<iostream>usingnamespacestd;classA{public:A(){cout<<"A";}~A(){cout<<"
有如下程序: #include <iostream> using namespace std; class B { public: virtual void show() { cout<<"B"; } };
随机试题
我国《法制日报》对法律所作的解释是_____________。
简述王明“左”倾教条主义的主要错误及其危害。
纤溶酶的主要作用是
下列药,擅治阳明经头痛的是
依据法律规定,债务人未向第三人履行债务或者履行债务不符合约定,应()。
—Emma,thanksfor______meyourpen.—You’rewelcome.
Accordingtoarecentsurvey,teachersarenotanymoreconsideredasgoodexamplesforstudents.Thelatterconsiderthattheb
“着色”的“着"应读作()。
Hurricanesareviolentstormsthatcausemillionsofdollarsinpropertydamageandtakemanylives.Theycanbeextremelydange
NowintheU.S.thewomenworkingoutsidehomecanget______.Theexpression"full-timehousework"inparagraph2means______
最新回复
(
0
)