Function call error??

Nov 11, 2015 at 8:06pm
I am trying to write a program where it inputs information from a file, and then sorts the information based on ID, Name, and Salary. Currently I am stuck on this first part and am getting a function call error that says

"error: no matching function for call to 'get_data'
get_data(inp, data, count);
^~~~~~~~"

Any help would be much appreciated.


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
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std; 

struct Employee{
int id;
string first;
string last;
double salary;
};

void get_data(ifstream &inp, Employee data[], int &count);

int main(){
int count = 0;
string input_filename;
string data;

cout << "Enter the name of the file you would like to be sorted: ";
	cin >> input_filename;
	ifstream inp;
	inp.open(input_filename.c_str());
	get_data(inp, data, count);


return EXIT_SUCCESS;
}

void get_data(ifstream &inp, Employee data[], int &count){

	do{
	inp >> data[count].id;
	inp >> data[count].first;
	inp >> data[count].last;
	inp >> data[count].salary;
	count++;
	}while(!inp.eof());
}

Nov 11, 2015 at 8:38pm
Your data on line 21 is of type string, not type Employee.
Nov 11, 2015 at 8:38pm
In main() what type of variable is data?

What type of variable does your function expect?

Are they the same types?


Nov 11, 2015 at 8:52pm
Thank you, I changed the string data to Employee data[] and it worked just fine. Much appreciated!
Topic archived. No new replies allowed.