Write the header file Car.h for the Car class. The Car class has three data memb
ID: 3828555 • Letter: W
Question
Write the header file Car.h for the Car class. The Car class has three data members: miles_per_gallon (double), fuel (double), and model (string). The Car class has a constructor that initializes each data member. The Car class has four additional member functions:
get_model : no parameters, returns model
drive : double miles parameter, returns nothing
add_fuel : double gallons parameter, returns nothing
low_on_fuel : no parameters, returns true or false
Do not provide the implementation of the member functions.
Explanation / Answer
Car.h
#ifndef Car_H
#define Car_H
class Car
{
public:
Car();
Car(double miles_per_gallon, double fuel, string model);
// Function declarations
void add_fuel(double gallons);
void drive(double miles);
string get_model();
bool low_on_fuel();
private:
//Declaring variables
double miles_per_gallon;
double fuel;
string model;
};
#endif
_______________Thank You
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.