Please help! I don't understand why I am getting this error: function does not take 0 arguments.

The program is suppose to calculate how much fuel is left in the tank after you drive a certain amount of miles.

Can someone please help explain why I am getting this error?



#include <iostream>
#include <cmath>

using namespace std;

class Car
	void read();
	void get_gas(double fuel_level);
	void print() const;
	double fuel_efficiency;
	double initial_fuel;
	double fuel_level;
	double distance;
	fuel_efficiency = 0;
	fuel_level = 0;
	distance = 0;
void Car::read()
	cout << " \n *** Car Class Testing Program *** \n ";
	cout << " Enter fuel efficiency in miles / per gallon: ";
        cin >> fuel_efficiency;  
        cout << " How many gallons of fuel did you start with?: ";
        cin >> initial_fuel;  
        cout << " How many miles will you be driving?: ";
        cin >> distance;
void Car::get_gas(double fuel_level)
	fuel_level = distance/fuel_efficiency - initial_fuel;
void Car::print() const
	cout << "After the drive you will have ";
	cout << fuel_level << " gallons of fuel left in the car";
int main()
	Car my_car;;

	return 0;

So, can you tell me how to fix it. I've been spending hours looking at this and changing things around with no success. I need to use the input from the read():: portion not actual numbers.

Thanks in advance!

void Car::get_gas()

While I'm here, take a close look at how you are calculating the fuel_level.

Edited 5 Years Ago by Moschops: n/a

What exactly is Car::get_gas() intended to do? It looks like you have it set up to do 2 different jobs, but you don't correctly implement/complete either job...

Is it intended to add gas to the vehicle ( void Car::get_gas(double) ), or is it intended to calculate fuel consumption ( double Car::get_gas(void) )? Notice the difference in the recommended prototypes.

Given the behavior of your Car::read() function and the calculation you perform within the Car::get_gas() function, it looks like it's intended to calculate consumption. Assuming that's true, Car::get_gas() will require a different prototype than what you have.

Edited 5 Years Ago by Fbody: n/a

Thanks everyone! I changed a few things and it works properly now. I appreciate the help!


This question has already been answered. Start a new discussion instead.