error code c2660

wow...no matter what I do this is the error message I continuously get for the code below....need some help to get rid of that error code...Visual Studio 2005 used as a compiler on a VISTA OS

" error C2660: 'calcMpg' : function does not take 2 arguments "

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <iomanip>

using std::cout;
using std::cin;
using std::endl;
using std::setprecision;
using std::fixed;

//function prototypes
double getMiles();
double getNumGallons();
double calcMpg();

int main()
{	
	//declare variables
	double miles       = 0.0;
	double gallons     = 0.0;
	double milesPerGal = 0.0;
	
	//enter input items
	miles = getMiles();
	gallons = getNumGallons();

	//calculate miles per gallon
	milesPerGal = calcMpg(getMiles, getNumGallons);

	//display output item
	cout << fixed << setprecision(1);
	
	cout << "Miles per gallon: " << milesPerGal << endl;

    return 0;
}   //end of main function

//*****function definitions*****
double getMiles()
{
	double numMiles = 0.0;
	cout << "Enter the number of miles: ";
	cin >> numMiles;
	return numMiles;
}	//end of getMiles function

double getNumGallons()
{
	double numGals = 0.0;
	cout << "Enter number of gallons: ";
	cin >> numGals;
	return numGals;
}	//end of getNumGallons function

double calcMpg(double mil, double gal)
{

	return mil/gal;
}	//end of calcMpg function


closed account (z05DSL3A)
1
2
3
4
5
6
7
8
9
10
11
//function prototypes
double getMiles();
double getNumGallons();
double calcMpg();
...
//Does not match prototype!
double calcMpg(double mil, double gal)
{

	return mil/gal;
}
1
2
3
4
5
6
7
8
9
10
//function prototypes
double getMiles();
double getNumGallons();
double calcMpg();
...
double calcMpg(double getMiles, double getNumGallons)
{

	return getMiles/getNumGallons;
}	//end of calcMpg function 


ok, so I made those changes and I am still getting the same error c2660...function does not take two arguments...
closed account (z05DSL3A)
The function protoype dose not match the function definition:
1
2
3
4
5
6
7
8
9
10
11
//function prototypes
double getMiles();
double getNumGallons();
double calcMpg();
...
//Does not match prototype!
double calcMpg(double mil, double gal)
{

	return mil/gal;
}

Change your function prototype as:
1
2
3
4
5
6
7
8
9
10
11
//function prototypes
double getMiles();
double getNumGallons();
double calcMpg(double mil, double gal);
...
//Does match prototype!
double calcMpg(double mil, double gal)
{

	return mil/gal;
}


call the function as:
1
2
3
4
5
6
    //enter input items
    miles = getMiles();
    gallons = getNumGallons();

    //calculate miles per gallon
    milesPerGal = calcMpg(miles, gallons);


or
milesPerGal = calcMpg( getMiles(), getNumGallons() );
Last edited on
Thank you so VERY much!

You have absolutely no idea what I went thru today trying to figure it out!

darn that was really quite easy!!!!

Thanks again!!!
Topic archived. No new replies allowed.