问题 填空题


试题源程序文件清单如下:
//main.cpp
#include<iostrcam.h>
class vehicle
private:
int MaxSpeed;
int Weight;
public:
//**********found**********
vehicle(int maxspecd,int weight): (1)
~vehiclc();
int getMaxSpeed()return MaxSpeed;
int getWeight()return Weight;
:
//**********found**********
class hicycle: (2) public vehicle
pnvate:
int Height;
public:
bicycle(int maxspeed ,int weight,int height):vehicle( maxspeed ,weight), Height( height)
int getHeight()return Height;;
;
//**********found**********
class motorcar: (3) public vehicle
private:
int SeatNum:
public:
motorcar( int maxspeed,int weight,int sealnum):vehicle( maxspeed, weight), SeatNum( seatnum)
int getSeatNum()return SeatNum;;
;
//**********found**********
class motorcycle: (4)
public:
motorcycle( int maxspeed ,int weight,int height):
vehicle( maxspeed ,weight), bicycle( maxspeed, weight, height), motorcar( maxspeed, weight,1)
;
void main()
motorcycle a(80,150,100);
cout<<a. getMaxSpeed()<<endl;
cout<<a. getWeight()<<endl;
cout<<a. getHeight()<<endl;
cout<<a. getSeatNum()<<endl;

答案

参考答案:MaxSpeed(maxspeed),Weight(weight){}

解析: “//**********found**********”下的语句是类vehicle的构造函数,需要补充初始化列表将其数据成员MaxSpeed和Weight初始化。

单项选择题
单项选择题