题目内容

请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,其中定义了vehicle类,并派生出motorcar类和bicycle类。然后以motocar和bicycle作为基类,再派生出motocycle类。要求将vehicle作为虚基类,避免二义性问题。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为:801501001注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动“//**********found**********”。#include<iostream.h>classvehicle{private:intMaxSpeed;intWeight;public://**********found**********vehicle(intmaxspeed,intweight):________________~vehicle(){};intgetMaxSpeed(){returnMaxSpeed;}intgetWeight(){returnWeight;}};//**********found**********classbicycle:________publicvehicle{private:intHeight;public:bicycle(intmaxspeedlintweight,intheight):vehicle(maxspeed,weight),Height(height){}intgetHeight(){returnHeight;};};//**********found**********classmotorcar:________publicvehicle{private:intSeatNum;public:motorcar(intmaxspeed,intweight,intseatnum):vehicle(maxspeed,weight),SeatNum(seatnum){)intgetSeatNum(){returnSeatNum;};};//**********found**********classmotorCyCle:________{public:motorcycle(intmaxspeed,intweight,intheight):vehicle(maxspeed,weight),bicycle(maxspeed,weight,height),motorcar(maxspeed,weight,1){}};voidmain(){motorcyclea(8.0,150,100);cout<<a.getMaxSpeed()<<end1;cout<<a.getWeight()<<end1;cout<<a.getHeight()<<end1;cout<<a.getSeatNum()<<end1;}

查看答案
更多问题

有如下类和对象的定义: class Constants {public:static double getPI() { return 3.1416; }};Constants constants;下列各组语句中,能输出3.1416的是( )。

A. cout B. cout<

下列关于函数模板的表述中,正确的是

A. 函数模板是一个实例函数
B. 使用函数模板定义的函数没有返回类型
C. 函数模板的虚拟类型参数就是函数参数
D. 通过使用不同的类型参数,可以从函数模板得到不同的实例函数

长效的糖皮质激素

A. 泼尼松
B. 氢化可的松
C. 地塞米松
D. 倍他米松
E. 氟氢可的松

用量过大可引起低血糖反应的药物是

A. 糖皮质激素
B. 胰岛素
C. 甲状腺激素
D. 炔雌醇
E. 螺内酯

答案查题题库