plz check this
/* A class car with three data menbers id,name and price of the car.It also contains the following member function.
* the get() function is used input values
* the show() function used to displays values.
* the set() function used to set values of data members using parameters.
* the getprice() function is used to return the values of car price.
create two object of class and display the all records of most costly car.
*/
#include<iostream>
using namespace std;
class car
{
private:
char car_id[20];
char car_name[20];
int car_price;
public:
void get();
void set(char n[],char id[] ,int p);
void show();
int getprice();
};
void car::get()
{
cout<<"enter car_id: "<<endl;
cin>>car_id;
cout<<"enter car_name; "<<endl;
cin>>car_name;
cout<<"enter car price: "<<endl;
cin>>car_price;
}
void car::set(char n[],char id[] ,int p)
{
strcpy(car_name,n);
strcpy(car_id,id);
car_price=p;
}
int getprice()
{
return car_price;
}
void show()
{
cout<<"ca name is "<<car_name;
cout<<"\ncar model is "<<car_id;
cout<<"price is "<<car_price<<endl;
}
int main()
{
car c1,c2;
c1.get();
c2.set("toyota","a123",200000);
if(c1.getprice()>c2.getprice())
c1.show();
else
c2.show();
return 0;
}