求教一个C++题目,大神来帮忙~~~~!!!!
来源:百度知道 编辑:UC知道 时间:2024/07/02 22:49:35
大神帮忙哇~~~
#include<iostream>
using namespace std;
class vehicle // 定义汽车类
{
public:
vehicle(int wheels,float weight);
int get_wheels();
float get_weight();
float wheel_load();
void show();
protected:
int wheels; // 车轮数
float weight; // 重量
};
class car:public vehicle // 定义小车类
{
public:
car(int wheels,float weight,int passengers=4);
int get_passengers();
void show();
private:
int passenger_load; // 载人数
};
class truck:public vehicle // 定义卡车类
{
public:
truck(int wheels,float weight,int passengers=2,float max_load=24000.00);
int get_passengers();
float efficiency();
void show();
private:
int passenger_load; // 载人数
float payload; // 载重量
};
vehicle::vehicle(int wheels,float weight)
{
vehicle::wheels=wheels;
vehicle::weight=weight;
}
int vehicle::ge