Quick "expected an expression" fix.

Just a simple question. I have this program that's giving me the above error at the end of some of my function calls.

Here's the prototype of the function I'm trying to call:

 
  void readFromFiletoArrays(ifstream& inf, string names[], double empData[][COLS], int &count);


And here's the function that's trying to call it. It happens right after count&.

1
2
3
4
5
6
7
8
9
10
11
12
13
void printAllEmployees(const string names[], const double empData[][COLS], const int count)
{
	ifstream inf;
	string name[10];
	double employeeData[ROWS][COLS];
	readFromFiletoArrays(inf, name, employeeData, count&);

	for (int i = 0; i < ROWS; i++)
	{
		cout << "Name       Hours     Rate      Weekly Salary" << endl;
		cout << name[i] << empData[i][0] << empData[i][1] << ((empData[i][0] * empData[i][1])) << endl;
	}
}
(ifstream& inf,

int &count)

these are both sent in by reference. So why do you send them in differently?

(inf,

count&);

change it to

readFromFiletoArrays(inf, name, employeeData, count); // removed & from count

Last edited on
I tried that, now it says "qualifiers dropped in binding reference of type "int &" to initializer of type "const int"" about "count". I can't change the function headers either because I need to use those exact ones to get credit.
Well, it wont work without changing it. Because int& count is not the same as const int count so you cant send that in as parameter. Either you're gonna have to change the readFromFile one to const int& count, or without reference.

void readFromFiletoArrays(ifstream& inf, string names[], double empData[][5], int count)

void readFromFiletoArrays(ifstream& inf, string names[], double empData[][5], const int &count)
Last edited on
Okay, how do I do it without reference? Is that one of the two examples you posted?
The first one is without reference, but without const either. Second one is both with const and reference.
Alright, thanks for the help!
Topic archived. No new replies allowed.