首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Cup{ public: Cup(double val=5.8):price(val) {
有如下程序: #include using namespace std; class Cup{ public: Cup(double val=5.8):price(val) {
admin
2021-07-02
23
问题
有如下程序:
#include
using namespace std;
class Cup{
public:
Cup(double val=5.8):price(val) { }
void SetPrice(double val) { price=val; }
double GetPrice() const { return price;}
private:
double price;
};
int main(){
const Cup c1(4.5);
Cup c2(29.8);
c1.SetPrice(5.8); //①
c2.SetPrice(12.8); //②
c1.GetPrice(); //③
c2.GetPrice(); //④
return 0;
}
在标注号码的语句行中存在语法错误的是
选项
A、①
B、②
C、③
D、④
答案
A
解析
本题考查常对象,常对象只能引用常成员函数,不能引用非常成员函数,所以①是错误的。答案为A选项。
转载请注明原文地址:https://kaotiyun.com/show/1efp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下类定义:classMyClass{Intvalue;public;MyClass(intn):value(n){}intgerValue()const{returnvalue;}
有如下程序:#include<iostream>usingnamespacestd;classBoat;classCar{public:Car(inti):weight(i){}
已知数组arr的定义如下:intarr[5]={1,2,3,4,5};下列语句中输出结果不是2的是()。
下列叙述中正确的是()。
若AA为一个类,a为该类的私有整型数据成员,getA()为该类的一个非静态公有成员函数,功能是返回a的值。如果x为该类的一个对象,要在类外访问x对象中a的值,正确的访问格式为()。
在下列枚举符号中,用来表示“相对于当前位置”文件定位方式的是()。
在下列原型所示的C++函数中,按“传值”方式传递参数的是()。
规范化主要为克服数据库逻辑结构中的插入异常,删除异常以及
支持子程序调用的数据结构是
如果一个模板声明列出了多个参数,则每个参数之间必须使用逗号隔开,每个参数都必须使用()关键字来修饰。
随机试题
女性,61岁,支气管哮喘史20年。6天前再次发作,经治疗后症状完全消失。2小时前突感左胸剧痛,继之呼吸困难、发绀、大汗、烦躁。血压90/60mmHg,气管右移,左肺呼吸音减低。病人最大可能是
确诊金黄色葡萄球菌肺炎的主要依据不包括
一患者被硬物撞击,经X线检查证实为上颌前部的牙槽突骨折伴牙龈撕裂伤,处理方法不正确的是
下列属于施工间接成本的有()。
人耳对声音大小的感觉,近似地与声压呈()关系。
北京龙华进出口公司从日本横滨进口了一批电子设备,货物于2004年1月8日从日本横滨启运,1月20日货物抵达天津港。抵达天津当日,龙华贸易公司委托永达报关行以龙华公司的名义向北京海关录入了该货物的电子数据中报,1月22日申报后生成的《进口转关货物申报单》被传
相对于其他种类的金融市场来说,我国的金融衍生品市场起步较晚,发展速度也较为缓慢。20实际世纪90年代初开始,我国开展金融期货交易试点,金融衍生品开始在我国出现。虽然我国金融衍生品还处于起步阶段,与其他金融市场相比还比较滞后,但随着我国经济的不断发展和经济全
某研究团队让两批测试者分别进入睡眠实验室里睡上一夜。第一批被安排睡得很晚,从而减少总睡眠时间;第二批被安排睡得很早,但在睡眠过程中多次被吵醒。第二晚过后,结果就已经显现:第二批测试者的积极情绪受到严重影响,他们的精力水平较低,同情心和友善度等积极情绪指数有
TheTVsetsmadebyourfactorysellbest,but10yearagonoonecouldhaveguessedtheplaceinthemarketthatthey______.
TheIndustrialRevolution[A]TheIndustrialRevolutionisthenamegiventothemassivesocial,economic,andtechnologicalchan
最新回复
(
0
)