首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Point{ public: Point(int xx=0,int yy=0):x(xx),
有如下程序: #include using namespace std; class Point{ public: Point(int xx=0,int yy=0):x(xx),
admin
2020-06-29
19
问题
有如下程序:
#include
using namespace std;
class Point{
public:
Point(int xx=0,int yy=0):x(xx),y(yy) { }
void SetX(int xx) { x=xx; }
void SetY(int yy) { y=yy; }
private:
int x,y;
};
class Circle:Point{
public:
Circle(int r):radius(r) { }
int GetRadius() { return radius; }
private:
void SetRadius(int r) { radius=r; }
int radius;
};
int main(){
Circle c1(5);
c1.SetX(1); //①
c1.SetY(2); //②
c1.SetRadius(10); //③
cout<
return 0;
}
在标注号码的语句行中不存在语法错误的是
选项
A、①
B、②
C、③
D、④
答案
D
解析
本题考查对象成员的引用,在类外引用对象的数据成员时,只能访问public成员而不能访问private成员所以C选项错误,D选项正确,派生类公用继承基类,但是不能继承基类的私有成员,所以执行c1.SetX(1)错误,同理B选项错误。
转载请注明原文地址:https://kaotiyun.com/show/JO8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下面程序输出的结果为()。#includevoidfun(inta,intb){inttemp;temp=a:a=b:b=temp;)voidmai
下列有关数据库的描述,正确的是()。
下列变量名中,合法的()。
使用VC6打开考生文件夹下的源程序文件modi2.cpp。请补充完整程序fun(inti),使程序完成以下功能:如果i=5,则输出如下5行井号。###############注意:不要
使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:Numbe=8注意:错误的语句在//********error********的下面,修改该语句即可。1
使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)定义复数类CComplex的私有成员变量real和imaginary,分别用来表示复数的实部和虚部,都是d
下列术语中,能表明面向对象思想主要特征的是
使用VC6打开考生文件夹下的源程序文件modi.cpp,该程序运行时有错,请改正其中错误,使得程序正常运行,并使程序输出的结果为:cTest注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在∥*******
下列关于类定义的说法中,正确的是()。
算法的有穷性是指()。
随机试题
A.龙胆泻肝汤B.一贯煎C.血府逐瘀汤D.柴胡疏肝散胁痛之肝络失养证,宜选用
肾癌侵犯大血管、肾上腺和肾周组织,局限于肾周筋膜内,按TNM分期,属于
为改善病人的心理状态,病室内墙壁的颜色宜使用()。
在工程索赔中,采用实际费用法计算工程索赔费用时,()即是承包商应得的索赔金额。
下列个人理财业务人员的行为没有违反《中国银行业从业人员职业操守》中“同业竞争”有关规定的是()。
共同配送是以城市一定区域内的配送需求为对象,人为地进行有目的集约化的配送。
其实,许多历史文化遗址,何止“普通”,有的甚至已经陈旧颓破。然而,这丝毫不影响其________。沧桑变迁,更是遗址上烙刻的不可复制的历史。文物的保护,也应包括对这种________逝去岁月“年轮”的保护。不仅是辛亥革命遗址,在凝结着屈辱与奋争的近代历史中
如图所示,以大圆的一条直径上的七个点为圆心,画出七个紧密相连的小圆。请问,大圆的周长与大圆内部七个小圆的周长之和相比较,结果是( )。
垄断资本所获得的高额利润,归根到底来自无产阶级和其他劳动人民创造的剩余价值。具体说,垄断利润的来源包括()
已知枚举类型定义语句为:enumToken{NAME,NUMBER,PLUS=5,MINUS,PRINT=10};则下列叙述中错误的是()。
最新回复
(
0
)