首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Pet{ char name[30]; public: Pet(char * n){ strcpy(name, n); } void bark(){ co
有如下类定义: class Pet{ char name[30]; public: Pet(char * n){ strcpy(name, n); } void bark(){ co
admin
2020-07-23
44
问题
有如下类定义:
class Pet{
char name[30];
public:
Pet(char * n){ strcpy(name, n); }
void bark(){ cout<<"Woof!"; }
};
且有如下变量定义:
Pet my_dog("Weiwei"), &p=my_dog;
则下列访问成员函数bark的表达式中,错误的是
选项
A、p.bark()
B、my_dog.bark()
C、p->bark()
D、(&p)->bark()
答案
C
解析
p为Pet类的引用类型,引用的对象是my_dog,p->bark()用法是错误的,至于选项D,&p是p的地址,通过地址使用箭头访问运算符访问bark(),正确;答案为C。
转载请注明原文地址:https://kaotiyun.com/show/6Lyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列关于模板形参的叙述中,错误的是
下列运算符只能重载为成员函数的一组是
有如下程序:#includeusingnamespacestd;void_________{intz=x;x=y;y=z;}intmain(){int
以下关键字不能用来声明类的访问权限的是()。
下列选项中属于面向对象设计方法主要特征的是( )。
下列关于this指针的描述中,正确的是()。
在定义一个类模板时,模板形参表是用一对括号括起来的,所采用的括号是
下面不属于软件需求分析阶段主要工作的是
在函数中,可以用auto、extern、register和static这四个关键字中的一个来说明变量的存储类型,如果不说明存储类型,则默认的存储类型是()。
在学生管理的关系数据库中,存取一个学生信息的数据单位是
随机试题
Manisendlesslyinventive.Buthisgreatestinventionisnon-invention,theskilloftransmittingintact(完美无损的)andunchangedfrom
下列影响股票投资价值的外部因素中,不属于宏观经济因素的是()。
在计算速动比率时,要从流动资产中扣除存货部分,再除以流动负债,这样做的原因是流动资产中()。
()是导游人员对待游客的个别要求和提供个性化服务应遵循的原则。
Inthefollowingtext,somesentenceshavebeenremoved.ForQuestions41-45,choosethemostsuitableonefromthelist(A、B、C、
在C语言中,只有在使用时才占用内存单元的变量,其存储类型是()。
Thesteadyhumofschoolheatingsystemsandair-conditionerscanmeanlowertestscoresformanyyoungstudents,foundanewst
FamousChristmasPlacesTherearemany【T1】______traditionsinChristmas.【T1】______ThetwofamousChristmasplacesare:1.Mid
Theold-fashionedgeneralstoreisfastdisappearing.Thisis,perhaps,apity,becauseshoppingtodayseemstolackthatperson
Yourweightaffectshowlongyoulive—butit’sextremelycomplicatedA)Weoftenthinkaboutweightlossintheshortterm,h
最新回复
(
0
)