首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
根据下面的程序,可以在主程序中使用的合法语句是( )。 #include <iostream> using namespace std; class Person{ int age; public:
根据下面的程序,可以在主程序中使用的合法语句是( )。 #include <iostream> using namespace std; class Person{ int age; public:
admin
2013-05-30
34
问题
根据下面的程序,可以在主程序中使用的合法语句是( )。 #include <iostream> using namespace std; class Person{ int age; public: void SetAge(int x){age=x;} void ShowAge(){cout<<"the Person’s age is" <<age;} }; class Student:private Person{ public:int study_code; }; void main(){ Student wangqiang; wangqiang.study_code=23; }
选项
A、wangqiang.age=231
B、wangqiang.Setage(23)
C、wangqiang.ShowAge()
D、wangqiang.study_code=12
答案
D
解析
由于是私有继承,基类中所有成员成为派生类中的私有成员,故不能由派生类的对象访问,只有派生类的公有成员可由派生类对象访问。
转载请注明原文地址:https://kaotiyun.com/show/g1Np777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
指针函数是说`函数的返回值是一个【】。
假定MyClas为一个类,那么该类的析构函数是()。
考虑函数原型voidfuc(intx,inty=5,charz=’*’),下面函数调用不合法的是()。
下面是一个栈类的模板,其中push函数将元素i压入栈顶,pop函数弹出栈顶元素。栈初始为空,top值为0,栈顶元素在stack[top-1]中,在下面横线处填上适当语句,完成栈类模板的定义。template<classT>classTstack
以下程序的运行结果是【】。#include<iostream.h>voidmain(){boolt1=8,t2=0,t3=1;cout<<t1<<’\t’<<t2<<’\t’<<t3<<end1;}
下面程序的输出结果是()。#include<iostream>usingnamespacestd;intfun(int,int);//fun()函数的说明voidmai
下面不属于软件工程3个要素的是()。
下面程序的输出结果是【】。#include<iostream.h>intd=1;intfun(intp){staticintd=5;d+=p;cout<<d<<"";
流程控制语句的基本控制结构有三种,不属于这一种结构的是()。
下面函数用来求出两个整数之和,并通过形参传回两数相加的结果。请将函数补充完整。intadd(intx,inty,【】z){【】=x+y;}
随机试题
教育督导的基本程序是()
适宜制成软胶囊剂的药物是
患者,男,40岁。左下胸受压,伴腹痛、恶心、呕吐入院。查体:面色苍白,四肢湿冷,脉搏125次/分,血压70/50mmHg,腹腔穿刺抽出不凝血。应采取的处理原则是()
周期非特异性抗恶性肿瘤药是
应根据何种用途对该两幢房屋进行估价?()该工厂若为扩大经营而筹集资金将该两幢房屋抵押,则为抵押目的评估的价值应为()。
有人认为校园欺凌和暴力行为只是有违道德的要求,并不违法。请简要谈谈你对该观点的认识。
幼儿教师最常用和最普遍使用的教育教学方法是()
下列______软件不是浏览软件。
Traditionally,universitieshavecarriedouttwomainactivities:researchandteaching.Manyexpertswouldarguethatboththes
AmitaiEtzioniisnotsurprisedbythelatestheadingsaboutschemingcorporatecrooks(骗子).AsavisitingprofessorattheHarva
最新回复
(
0
)