#include<iostream.h>
class vehicle // 定义汽车类
{
protected:
int wheels; // 车轮数
float weight; // 重量
public:
vehicle(int wheels,float weight);
int get_wheels();
float get_weight();
float wheel_load();
void show();
};
class car:public vehicle // 定义小车类
{
int passenger_load; // 载人数
public:
car(int wheels,float weight,int passengers=4);
int get_passengers();
void show();
};
class truck:public vehicle // 定义卡车类
{
int passenger_load; // 载人数
float payload; // 载重量
public:
truck(int wheels,float weight,int passengers=2,float max_load=24000.00);
int get_passengers();
float efficiency();
void show();
};
vehicle::vehicle(int wheels,float weight)
{
vehicle::wheels=wheels;
vehicle::weight=weight;
}
int vehicle::get_wheels()
编写一个程序设计一个汽车类vehicle,包含的私有数据成员有车轮个数wheels和车重weight
最新推荐文章于 2023-04-10 15:04:29 发布