首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
在下列的程序的横线处填上适当的语句,使该程序的输出为12。 #include<iostream> using namespace std; class TestClass { public: int a,b
在下列的程序的横线处填上适当的语句,使该程序的输出为12。 #include<iostream> using namespace std; class TestClass { public: int a,b
admin
2010-06-06
25
问题
在下列的程序的横线处填上适当的语句,使该程序的输出为12。
#include<iostream>
using namespace std;
class TestClass
{
public:
int a,b;
TestClass(int i,int j)
{
a=i;
b=j;
}
};
class TestClass1:public TestClass
{
int a;
public:
TestClass1(int x):TestClass(x,x+1){}
void show()
{
______;//输出基类数据成员a的值?
cout<<b<<endl;
}
};
int main()
{
TestClass1 d(1);
d.show();
return 0;
}
选项
答案
cout<<TestClass::a
解析
题目中程序TestClass为基类,TestClass1为派生类,在主函数中定义TestClass1对象d(1)。根据题目要求“输出基类数据成员a的值”,基类为TestClass,利用::域运算符取其成员a的值。
转载请注明原文地址:https://kaotiyun.com/show/Zejp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
若有“doublea;”,则正确的输入语句是()。
若下列选项中的各变量均为整型且已有值,其中不正确的赋值语句是()。
有以下程序段intj;floaty;charname[50];scanf("%2d%f%s",&j,&y,name);当执行上述程序段,从键盘上输入555667777abc后,y的值为()。
编写一个函数,从num个字符串中找出最长的一个字符串,并通过形参指针max传回该串地址。(注意:主函数中用料料作为结束输入的标志。)注意:部分源程序在文件PROGl.C中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花
设有以下说明,则不正确的叙述是()。unionun{inta;charb:floatc;}art;
请编写函数fun,该函数的功能是:删除一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。例如,若一维数组中的数据是:22234456666778991
给定程序中,函数fun的功能是建立一个NxN的矩阵。矩阵元素的构成规律是:最外层元素的值全部为1;从外向内第2层元素的值全部为2;第3层元素的值全部为3,…依次类推。例如,若N=5,生成的矩阵为:11111
下面属于黑盒测试方法的是
有如下程序#include<stdio.h>int*sum(intdata){staticintinit=0;init+=data;return&init;}main(){inti
下面的程序在编译时产生错误,其出错原因是()。#include<stdio.h>main(){int1case;floatprintF;printf("请输入2个数:");sc
随机试题
下列选项中,属于妊娠期慎用的药物有
什么叫电弧静特性?什么叫电源的外特性?
腹上角又称为
最易引起休克的肾损伤是
A、1gB、2~5gC、6~9gD、10gE、20g除另有规定外,含毒剧药的酊剂每1OOml相当于原药材
不同土地间或同一土地上的级差地租是由()因素造成的。
某投资者2002年准备投资购买股票,现有A、B两家公司可供选择,从A、B公司2001年12月31日的有关会计报表及补充资料中获知,2001年A公司发放的每股股利为5元,股票每股市价为40元;2001年B公司发放的每股股利为2元,股票每股市价为20元。预期A
__________是先于学习任务本身呈现的一种引导性材料,它要比原学习任务本身有更高的抽象、概括和包容水平,并且能清晰地与认知结构中原有的观念和新的学习任务关联起来。
Peopleare,onthewhole,pooratconsideringbackgroundinformationwhenmakingindividualdecisions.Atfirstglancethismigh
BIRD-Xofferspestbirdcontrolproductsto______,controlandgetridofbirds.
最新回复
(
0
)