数据结构的题目如下,希望高手帮忙解决,谢谢哈,急用、、、、、

1定义一个汽车类(car),至少包括构造函数,汽车行驶、停车等成员函数和型号、价格。重量、油耗、行驶速度等成员变量。2将(1)中提到的成员变量定义为私有访问权限,将成员函... 1 定义一个汽车类(car),至少包括构造函数,汽车行驶、停车等成员函数和型号、价格。重量、油耗、行驶速度等成员变量。
2 将(1)中提到的成员变量定义为私有访问权限,将成员函数定义为共有访问权限。
3 在主函数中定义三个汽车类的对象,并调用相关的成员函数。
展开
 我来答
小叶一片
2011-04-01 · TA获得超过123个赞
知道小有建树答主
回答量:97
采纳率:0%
帮助的人:105万
展开全部
#include<iostream.h>
#include<string>
using namespace std;
class car
{
private:
string style;//车型
float weight;//重量
float fconsum;//油耗
float speed;//速度

public:
car(string style,float weight,float fconsum,float speed)//构造函数
{
this->style = style;
this->weight = weight;
this->fconsum = fconsum;
this->speed = speed;
}

void driving();//行驶
void stop();//停车
void printstyle();//输出车型

};

void car::driving()
{
cout<<"车在行驶..."<<endl;
}
void car::stop()
{
cout<<"车已停"<<endl;
}
void car::printstyle()
{
cout<<style.data();
}
void main()
{
car c1("宝马",1500,1.2,80);
car c2("大众",1300,1.1,75);
car c3("奔驰",1400,1.3,85);

c1.printstyle();
c1.driving();
c1.printstyle();
c1.stop();

c2.printstyle();
c2.driving();
c2.printstyle();
c2.stop();

c3.printstyle();
c3.driving();
c3.printstyle();
c3.stop();
}
光点科技
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件... 点击进入详情页
本回答由光点科技提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式