帮我恢复下面的c ++程序 [英] Help me resove the below c++ program

查看:85
本文介绍了帮我恢复下面的c ++程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

汽车销售员希望实施一个信息系统,存储他销售的汽车的详细信息,即汽车的品牌,车型的发布年份,汽车的价格和里程数。创建一个c ++类汽车,其中包含:

所有数据成员都包含上面指出的详细信息



一个构造函数,用于初始化每个数据成员值如下所示



制作:默认

年份:2005

价格:500,000

里程:10,000



一个setDetails函数,用于捕获用户对汽车对象的上述细节



一个getDetails函数打印出汽车对象的所有细节

A car salesman wants to implement an information system that stores details about the car he sells,i.e the make of the car, year the model was released, the price and the mileage on the car. create a c++ class car that has:
All the data members included the details indicated above

A constructor that initializes each data member with the values indicated below

Make:default
Year:2005
Price:500,000
Mileage:10,000

A setDetails function that captures the above details from a user for a car object

A getDetails function that prints out all the details for a car object

推荐答案

我们不做你的功课:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是你想的很难!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!


Class clsnme

{

public int year,price,mileage;



//构造函数



class clsnme

{

int year = 2005,价格= 50000,里程= 10000;

}



//设置详情:



public void setdetails

{

cout<<输入年份:;

cin>>年;

cout<<\ n输入价格:;

cin>>价格;

cout<< \ n输入里程:;

cin>>里程;

}



//获取详情



Public void getdetails

{

cout<<Y ear:<<<<<"\ n;

cout<<Price:<<\ n;

cout< ;<里程:<<\ n;

}



}





在主要任何地方调用这些函数。如果你打印而不调用setdetails,它将在构造函数中打印值。否则它将从用户获取值(如果调用了setdetails())。希望它能起作用
Class clsnme
{
public int year, price,mileage;

//Constructor

class clsnme
{
int year=2005,price=50000,mileage=10000;
}

//Set Details:

public void setdetails
{
cout<<"Enter the Year:";
cin>>year;
cout<<"\nEnter the Price:";
cin>>price;
cout<<"\nEnter the Mileage:";
cin>>mileage;
}

//Get Details

Public void getdetails
{
cout<<"Year:<<year<<"\n";
cout<<"Price:<<"\n";
cout<<"Mileage:<<"\n";
}

}


Call these functions in main wherever you want. If u Print without calling setdetails it will print values in constructor. Or otherwise it will get values from user (if setdetails() called). Hope it will work


这篇关于帮我恢复下面的c ++程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆