首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class Wheel{ public: Wheel(string s=
有如下程序: #include #include using namespace std; class Wheel{ public: Wheel(string s=
admin
2020-10-21
11
问题
有如下程序:
#include
#include
using namespace std;
class Wheel{
public:
Wheel(string s="W"):name(s) { cout<
~Wheel() { cout<
private:
string name;
};
class Bicycle{
public:
Bicycle(string br="G",string f="F",string r="R"):brand(br),rear(r),front(f) { cout<
~Bicycle() { cout<
private:
Wheel front,rear;
string brand;
};
int main(){
Bicycle bike;
return 0;
}
运行时的输出结果是
选项
A、RFG
B、FRG
C、FRGGRF
D、FRGFRG
答案
C
解析
定义Bicycle bike时,执行Wheel的构造函数输出FR,然后执行Bicycle的构造函数输出G,最后执行析构函数,一次执行派生类的析构函数输出G,再输出基类的析构函数输出RF,最终输出FRGGRF,选项C正确。
转载请注明原文地址:https://kaotiyun.com/show/R5yp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列选项中不属于软件生命周期开发阶段任务的是()。
有如下程序:#includeusingnamespacestd;classToy{public:Toy(char*_n){strcpy(name,_n);count++;}~
将运算符重载为类成员函数时,其参数表中没有参数,说明该运算符是()。
有如下程序:#includeUsingnamespacestd;ClassAmount{intamount;public;Amount(intn=0):amount(n){}
下列语句中,错误的是()。
下列符号中能够作为C++标识符的是()。
下列链表中,其逻辑结构属于非线性结构的是()。
下列关于C++预定义流对象的叙述中,正确的是()。
下列符号中能够作为C++标识符的是()。
算法的时间复杂度是指()。
随机试题
呋喃唑酮的用途应除外:
75岁女患者,右大腿卵圆窝部反复出现圆形包块10年,此次因便秘突出包块过大,用力还纳后右下腹持续疼痛伴呕吐而求医。下腹压痛,肌紧张,叩诊肝浊音界缩小,肠鸣音消失。此患者直肠右侧壁有触痛,子宫直肠窝有液性暗区,白细胞计数2×109/L,中性粒细胞80%,
安德森认为心智技能的形成包括()。
任何记忆系统中信息保持的时间都不可能长达终身。()
广泛使用的电子邮件地址的格式是ABC@njupt.edu。其中,njupt.edu是指(56)。
Usingtheinformationinthetext,completeeachsentence14-18withanexpressionfromthelistbelow.Foreachsentence(14
Howmanyplanetsarethereinthesolarsystemrevolvingaroundthesun?
Heneverhesitatestomakesuchcriticisms______areconsideredhelpfultoothers.
"Andshetiedabunchofvioletswithatressofherprettybrownhair."Shesatintheyellowglowofthelamplightsoftl
Nowthenextthingyoumustdowhenyoulistenisthatyouneedto【T1】______thatthelecturerexpectsyoutoadd.Alllecturers
最新回复
(
0
)