首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下类定义 classPoint{ public: Point(int x=0,int y=0){_x=x;_y=y;} void Move (int xOff,int yOff {_x +=xOff;_y
有以下类定义 classPoint{ public: Point(int x=0,int y=0){_x=x;_y=y;} void Move (int xOff,int yOff {_x +=xOff;_y
admin
2017-10-17
5
问题
有以下类定义 classPoint{ public: Point(int x=0,int y=0){_x=x;_y=y;} void Move (int xOff,int yOff {_x +=xOff;_y+yOff} void Print() const {cout<<’(’<<_x<<’,’<<_y<<’)’<<endl;} private: int_x_y; }; 下列语句中会发生编译错误的是
选项
A、Pointpt;pt;Print();
B、const Point pt;pt.Print();
C、Pointpt;pt.Move(1,2);
D、const Point pt;pt.Move(1,2);
答案
D
解析
本题考核常对象、常数据成员与常成员函数。如果将一个对象说明为常对象,则通过该常对象只能调用它的常成员函数,不能调用其他的成员函数,D选项中对象 pt为常对象,而成员函数Move()不是常成员函数,所以这样调用会发生编译错误。
转载请注明原文地址:https://kaotiyun.com/show/DPAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
软件生命周期包括八个阶段。为使各时期的任务更明确,又可以分为以下三个时期:软件定义期,软件开发期,软件维护期。编码和测试属于【 】期。
设有char str[80]以下不能将输入数据first\nsecond\n<CR>读取到数组sir中的语句是
关于常成员函数,下列说法中错误的是
()是一个在基类中说明的虚函数,它在该基类中没有定义,但要求任何派生类都必须定义自己的版本。
下列叙述中正确的是
在重载一个运算符为成员函数时,其参数表中没有任何参数,这说明该运算符是()。
运算符函数调用格式的表达式y/x++与表达式y.operator/(operator++(x,0))的含义相同,由此可看出()。
有如下定义:classMA{intvalue;public:MA(intn=0):value(n){}};MA*ta,tb;其中MA类的对象名标识符是______
利用成员函数对双目运算符重载,其左操作数为______,右操作数为______。
随机试题
麻黄碱滴鼻治疗鼻塞已被羟甲唑啉取代。
简述公共政策变动的原因。
甲市人民政府决定,一项地方规章由于客观情况发生重大变化而失效,下列与此相关的表述中,正确的有()。
在进行员工满意度调禽时,要根据()确定调查的内容。
陈鹤琴主张教育的设计性、整体性、________三者结合的教学法,强调从幼儿的认知水平、能力、经验、兴趣出发,在他们所直接接触到的自然与社会环境中选取中心。
(2009年真题)如图3.11,长方形ABCD中,AB=a,BC=b(b>a),若将长方形ABCD绕A点顺时针旋转90°,则线段CD扫过的面积(阴影部分)等于[]。
下列选项中,属于犯罪预备行为的有()。
MindYourCaloriesorYourWaistline?Cuttingbackthecaloriesmaydomorethanwhittleyourwaistline;itcouldprotecty
TowardstheendofJune,auniquejointexpeditionbeganinthewatersnearIndonesia.Inanareaofremarkablemarinediversity
Itisdifficulttobelievethat,onlyeightyyearsago,theideaofthedomesticelectriclightwasheldincontemptbyallthe
最新回复
(
0
)