卓别林自传英文版:C++考题 关于定义类 帮我!

来源:百度文库 编辑:高考问答 时间:2024/04/28 12:45:34
将公路上的车辆作为对象考虑,它可以包含哪些数据和函数?定义这样的一个类.

属性(数据):颜色,速度,品牌,体积,状态,载重量
操作(函数):启动,刹车,开门,关门

急!明天评出最佳,谢谢帮忙!

class bus
{
private:
int color; //颜色
float speed; //速度
char *brand; //品牌
float volume; //体积
int status; //状态
float load; //载重量

public:
bus(); //构造函数
int Start(); //启动
int Break(); //煞车
int OpenDoor(); //开门
int CloseDoor(); //关门
};

class bus{
private:
int color;
float speed;
char *brand;
float v;
int status;
float weight;

public:
bus(){}
int start(){}
int break(){}
int opendoor(){}
int closedoor(){}
};

class Car
{
public:
int color; //颜色
double rate; //速度
int brand;//品牌
double volume; //体积
int state; //状态
double load; //载重量

void start();
void brake();
void Open_door();
void Close_door();
}