首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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-10-21
16
问题
有如下程序:
#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:public 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、④
答案
C
解析
本题考查对象成员的引用,在类外引用对象的数据成员时,只能访问public成员而不能访问private成员所以C选项错误。
转载请注明原文地址:https://kaotiyun.com/show/skyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列有关类继承的叙述中,错误的是()。
下列关于运算符函数的描述中,错误的是()。
已知枚举类型声明语句为:enumCOLOR{WHITE,YELLOW,GREEN=5,RED,BLACK=10};则下列说法中错误的是()。
下列有关内联函数的叙述中,正确的是()。
结构化程序设计的基本原则不包括()。
下列关于类和对象的叙述中,错误的是()。
使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)完成默认构造函数TestClass的定义,使得TestClass对象的类型为int,默认值为a=0,b=0,c=0,请在注释//
建立一个类对象时,系统自动调用()。
下列选项中,不是C++关键字的是()。
下列有关模板的叙述中,正确的是()。
随机试题
达赖喇嘛被认为是观世音菩萨的化身。()
可同时进行治疗药物及其代谢物浓度监测的技术是
华新基金管理公司是信泰证券投资基金(信泰基金)的基金管理人。华新公司的下列哪些行为是不符合法律规定的?(2012年试卷三第73题)
1960年,法国总统戴高乐听到法国成功试验原子弹的消息后高呼:“法国万岁!从今天早上起,她更加强大了,更加骄傲了……”能够和这一情景联系起来的是()。
右边给出了四个图形,只有一个是由左边的四个图形拼合(只能通过上、下、左、右平移)而成的。请你把它找出来。
简述《白鹿洞书院揭示》的教育宗旨。(2019年南京师大、2014年华东师大、2013年西北师大)
下列关于Internet的叙述中,错误的是
数据模型所描述的内容通常由数据结构、数据操作和【】三部分组成。
Humansaresocial(11).Theyliketoliveandworkingroups,andtherefore,theyformcouplesandfamilies,villagesandcitie
Thedifferencebetweenaliquidandagasisobvious【C1】______theconditionsoftemperatureandpressurecommonlyfound【C2】_____
最新回复
(
0
)