Hi everyone, I wanted to write a class allowing a user to enter information about his or her car. I already have an idea of how to write it but for some reason I feel that something is wrong in the way I've written it.
I haven't completed the code since I just started it but I wanted it to take in all of the information (doors, cylinders, and transmission) and output the type of car the user has (suv/sportrscar). I've done it with the doors already just to give you an example.
Please let me know if I'm on the right track or if I will cause a lot of errors if I continue to complete the code this way.
Code:
#include <iostream.h>
class Vehicle
{
public:
Suv();
Sportscar();
private:
int doors;
int cylinders;
int name;
int color;
int transmission;
};
Vehicle::Suv()
{
cout<<" How many doors does the car have? ";
cin>>doors;
if (doors>=4)
cout<<" You are driving an SUV"<<endl;
else
cout<<" You are driving a sportscar"<<endl;
}
Vehicle::Sportscar()
{
cout<<" How many doors does the car have? ";
cin>>doors;
if (doors<4)
cout<<" You are driving a sportscar"<<endl;
else
cout<<" You are driving an SUV"<<endl;
}
int main()
{
Vehicle c;
c.Suv();
c.Sportscar();
return 0;
}