首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的运行结果为【 】。 #include <iostream. h> class myclass { private: int a, b, c; public
下列程序的运行结果为【 】。 #include <iostream. h> class myclass { private: int a, b, c; public
admin
2010-06-06
21
问题
下列程序的运行结果为【 】。
#include <iostream. h>
class myclass
{
private:
int a, b, c;
public:
void fun()
{
int a;
a=10;
this->,a=5;
b=6;
this->c=7;
cout<<"a="<<a<<",this->a="<<this->a<<endl;
}
};
void main()
{
myclass obj1;
obj1.fun()
}
选项
答案
a=10, this->a=5
解析
本题考察在类的成员函数定义中,如果出现类的数据成员和成员函数的局部变量同名的情况下,如何正确引用合适的变量或数据成员。本题巧妙的采用了this指针完成这种标识。
转载请注明原文地址:https://kaotiyun.com/show/V4jp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
阅读以下程序#include<stdio.h>main(){IntCase;floatprintF;printf("请输入2个数:");scanf(,"%d%f",&Case,&printF);printf("%d%f\n",Case,pr
有以下定义和语句structworkers{intnum;charname[20];charc;struct{intday;intmonth;intyear;}s;
当没有指定c语言中函数形参的存储类别时,函数形参的存储类别是()。
有如下定义structst{intn;floatt;}a[20];FILE*fp;若文件已正确打开,则以下将文件内容读入数组a中的语句错误的是
构成C语言程序的三种基本结构是()。
公司中有多个部门和多名职员,每个职员只能属于一个部门,一个部门可以有多名职员。则实体部门和职员间的联系是
有如下程序#include<stdio.h>#include<string.h>main(){printf("%d\n",strlen("0\t\nA011\1"));}程序运行后的输出结果是
下列选项中,能够满足"只要字符串s1等于字符串s2,则执行ST"要求的是
有以下字符串,说明表达式strlen(s)值的是()。chars[10]={’a’,’\n’,’a’,’b’,’\t’,’c’};
对长度为n的线性表排序,在最坏情况下,比较次数不是n(n-1)/2的排序方法是( )。
随机试题
WHO于1973年提出了盲和视力损伤的分类标准,将盲和低视力分为几级
岩的主要病因病机是
肾综合征出血热早期休克的原因是
在进行投资方案现金流量基本要素分析时,下列补贴中()不能作为项目的财务效益中补贴收入。
进出口许可证制度属于贸易管制中的非关税措施。()
某学校甲、乙、丙三位老师年龄各不相同,一位喜欢足球,一位喜欢篮球,一位喜欢排球。现在知道:甲比喜欢足球的人年龄大;喜欢排球的老师比喜欢篮球的老师年龄小;乙老师年龄最大。由此可以推出()。
在行动研究中,被研究者是研究的()。
Nomatterwhoyouareorwhereyoucomefrom,onethingiscertain:youareacquaintedwiththemosquito(蚊子)—althoughyouprobab
Weknowourfriendsbytheirdefects______bytheirmerits.
A)Inthisarticle,we’lllookattherulesfor529QualifiedStateTuitionPlans.We’llexplorethedifferencebetweenthissav
最新回复
(
0
)