首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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-05-06
48
问题
有如下程序:
#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://jikaoti.com/ti/FSh0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#include#includeusingnamespacestd;intmain(){cout
有如下程序:#include<iostream>usingnamespacestd;classBase{public:virtualvoidShow(){cout<<’B’;}};
下列关于软件工程的描述中正确的是()。
数据库DB、数据库系统DBS、数据库管理系统DBMS之间的关系是()。
下列给定程序中函数fun的功能是:在字符串的最前端加入n个水号,形成新串,并且覆盖原串。字符串的长度最长允许为79。请改正程序中的错误,使它能得出正确的结果。注意:部分源程序在文件NODII.C中,不要改动main函数,不得增
在下列选项中,不允许作为C++标识符的是
软件设计中模块划分应遵循的准则是()。
定义无符号整数类为UInt,下面可以作为类UInt实例化值的是()。
设一棵完全二叉树共有700个结点,则此二叉树中的叶子结点数为()。
深度为7的完全二叉树中共有125个结点,则该完全二叉树中的叶子结点数为
随机试题
下列药物中易诱发心律失常的是
血中直接测定的HCO3-实际数值应表示为
患者,女性,42岁,糖尿病病史3年,某日餐前突然感到饥饿难忍、全身无力、心慌、出虚汗,继而神志恍惚。护士应立即采取的措施是()。
锅炉的水位是保证供汽和安全运行的重要指标,操作人员应不断地通过()监视锅内的水位。
从本质上讲,企业价值评估的对象是()。
22,35,55,88,141,()
“才者,德之资也;德者,才之帅也。”下列对这句话理解正确的是()。
Inthefollowingarticle,somesentenceshavebeenremoved.ChoosethemostsuitableonefromthelistA—Gtofitintoeachoft
MarkingthefifthWorldIntellectualPropertyDayonApril26,theDirectorGeneraloftheWorldIntellectualPropertyOrganizat
A、Whencanyougo?B、Howmuchisit?C、Whereisit?D、Whatwillyoudo?AI’mhopingtovisityourshowroom.MayI?
最新回复
(
0
)