I'm missing something really basic on this one I'm sure. We have to write a program using a class Odometer, that will track fuel and mileage of a car. The member functions are given: one to set fuel efficiency, one to accept total miles driven and add to the odometer total, one that will return the number of gallons of gasoline that the vehicle has consumed since resetting. I'm receiving a linker 1120 "cannot find file Odometer.exe." I've tried saving the project and reopening, to no avail. At one point, it DID compile! I have other problems with my main, but obviously need to resolve this one first. I am a newbie, and have Finals and many more projects due...
Thank you for any help

#include <iostream>
using namespace std;

class Odometer

{
public:
	Odometer();
	void reset();
	void compute_fuel();
	void input_miles(int getmiles);
	void Odometer::set_fuel_efficiency(double fuel_efficiency);
	double Odometer::get_num_gallons();
	int gallons_consumed;


private:
	int miles_tracker;
	double fuel_efficiency;
	int getmiles;
	
	
};

Odometer::Odometer()
{
	
	miles_tracker = 0;
	fuel_efficiency = 0;
	
}



void Odometer::reset()
{
	miles_tracker = 0;
}



void Odometer::compute_fuel()
{
	fuel_efficiency = (miles_tracker/gallons_consumed)
}



void Odometer::input_miles(int miles_driven)
{
	miles_tracker = miles_tracker + miles_driven;

}




void Odometer::set_fuel_efficiency(double Fuel_efficiency)
{
	fuel_efficiency = Fuel_efficiency;
}

double Odometer::get_num_gallons()
{
	return miles_tracker/fuel_efficiency;
}




	 


int main()
{

	Odometer simulator;
	int miles_driven;
	simulator.input_miles(int miles_driven);


	cout << "Please enter the amount of miles driven : " << endl;
	cin >> miles_driven;


    //simulator.set_fuel_efficiency(double fuel_efficiency);
	//cout <<"Enter your amount of fuel in gallons: " << endl;
	//in >> 

return 0;

A function is a function, whether it is a method or not. You must call it correctly, and in the right place:

Odometer simulator;
  int number_of_miles_driven;

  cout << "Please enter the amount of miles driven : " << endl;
  cin >> number_of_miles_driven;

  simulator.input_miles(number_of_miles_driven);

Notice how I changed the name of the variable to "number_of_miles_driven"? This is to remind you that the name of the variable you use doesn't have to be the same as the name of the function's parameter (which I didn't change from "miles_driven").

You seem to be a little confused about how your class is going to work...

Hope this helps.

A function is a function, whether it is a method or not.......

Duoas,

Thank you, that works of course...I keep forgetting basic rules with functions and their attendant parameters....I thought because I had changed my parameters from my "input_miles(int getmiles)" declaration to "input_miles(int miles_driven)" in my definition, that in main I could successfully utilize the int miles_driven!?? I am still shaky on this and will have to understand
As Always, many thanks,
RG

C and C++ purists tend to get heated about terminology for this stuff, but the difference is:

A parameter is the name of something passed to a function. void foo( int a_number, bool is_prime ) a_number and is_prime are parameters.

An argument is the value you pass to a function: foo( 42, false ); 42 and false are arguments. Th

(In C they call them "arguments" and "argument values" respectively.)

Hope this helps.

This article has been dead for over six months. Start a new discussion instead.