define a class called vehicle that will store two items of information about a vehicle: the fuel capacity and the fuel consumption in kilometers per litre and prototype of four functions a default constructor and a parameterized constructor that initializes the taxi fuel capacity to 20 litres and taxi consumption to 10 kpl , a destructor and a friend function that uses the values from the constructors to calculates the taxi range (the maximum distance it would travel if its fuel tank is full without refueling) nb. show only the prototype of the function in the class
#include <iostream>
using namespace std;
class vehicle{
private:
int fuelCapacity;
int fuelConsumption;
public:
vehicle(){
}
vehicle(int cap,int con){
fuelCapacity=20;
fuelConsumption=10;
}
void setFuelCapacity(int cap);
void setFuelConsumption(int con);
int getFuelCapacity();
int getFuelConsumption();
friend void calculate();
~vehicle(){
}
};
void vehicle :: setFuelCapacity(int cap){
fuelCapacity=cap;
}
void vehicle :: setFuelConsumption(int con){
fuelConsumption=con;
}
int vehicle::getFuelCapacity(){
return fuelCapacity;
}
int vehicle::getFuelConsumption(){
return fuelConsumption;
}
int main()
{
vehicle v;
return 0;
}
Comments
Leave a comment