首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
2015-07-22
51
问题
有如下程序:
#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/kkNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在定义类的对象时,C++程序将自动调用该对象的【】函数初始化对象自身。
在不同文件的函数中,对非静态全局变量的引用要加的关键字是()。
数据的逻辑独立性是指()。
下列程序的输出结果为2,请将程序补充完整。#include<iostream>usingnamespacestd;classBasc{public:【】voidfun(){cout<<1;}
有以下程序#include<iostream>usingnamespacestd;classsample{private:intx;public:sample(
已知:doubleA(doubleA){return++a;}和intA(intA){return++a;}是一个函数模板的两个实例,则该函数模板定义为【】
下列关于栈的叙述正确的是
在软件生存周期中,能准确地确定软件系统必须做什么和必须具备哪些功能的阶段是
假设a、b均是整型变量,则表达式a=2,b=5,a++,b++,a+b值为【】。
在类的定义中,用于为对象分配内存空间,对类的数据成员进行初始化并执行其他内部管理操作的函数是
随机试题
Theyoungergeneration______greatlyfromtheoldergenerationinmanyways.
对于蛋白质二级结构不正确的叙述是
账务处理模块中会计科目设置好后,也可随时变动。()
以()财产做抵押的,应当办理抵押登记,抵押权自登记时设立。
()适用于表彰先进、批评错误、传达重要精神和告知重要情况。
职业道德范畴是反映职业道德现象的特性、方面和关系的基本概念,以下不属于社会主义职业道德范畴的是()。
The______resultwillbeannouncednextweek.
Announcementfrom[Student]ServicesTheSybertUniversity[Student]ServicesDepartmentishappytoannounceanewtransport
TheU.S.aircraftmanufacturerBoeingCompanyisdenyingreportthat______.
Ifyouwanttoteachyourchildrenhowtosaysorry,youmustbegoodatsayingityourself,especiallytoyourownchildren.Bu
最新回复
(
0
)