Error C2664!

I get an error C2664: 'Process_Data' : cannot convert parameter 2 from 'Stud' to 'Stud []'

:^(


I tried searching the forums before posting and I found that adding another [] to the prototype would normally fix the issue, but it didn't seem to help with my program.

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
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#define Size 20

using namespace std;

struct Stud{
	string Name;
	long ID;
	float GPA, SPoints;
	int SUnits;
	char Grade;
};

struct PStud{
	Stud list[Size];
};
void Process_Data(ifstream, Stud, PStud &, int &);
float Assign_GPA(char);
void Process(int, float, float &, int &);
bool Verify(int);
bool Open_File(ifstream &);
bool Open_File2(ofstream &);

int main()
{
	Stud TEMP[Size];
	PStud Stud;
	string Name, FName;
	ifstream Input;
	ofstream Output;
	int Num = 0;
	int counter = 0, SUnits = 0, Tot_Units = 0;
	float SPoints = 0, Tot_Points = 0, GPA, Tot_GPA;

	if (Open_File(Input))
	{
		if (Open_File2(Output))
		{
			Output << setprecision(2) << fixed << showpoint;
			cout << left << setw(27) << cout << left<<setw(27)<<"\n\nStudent Name" << setw(10)<<"ID "<<setw(10)<<"Units" <<setw(8)<<"GPA" <<endl;
			cout <<"====================================================\n";
			Output << left<<setw(27)<<"\n\nStudent Name" << setw(10)<<"ID "<<setw(10)<<"Units" <<setw(8)<<"GPA" <<endl;
			Output <<"====================================================\n";
			getline(Input,TEMP[Num].Name);
			while(!Input.eof())
			{
				Input >> TEMP[Num].ID;
				Process_Data(Input, TEMP, Stud, Num);
				cout << setw(25) << Name << setw(10) << TEMP[Num].ID << setw(10) << TEMP[Num].SUnits << setw(8) << TEMP[Num].GPA <<endl;
				Output << setprecision(2)<<fixed;
				Output << setw(25) << Name << setw(10) << TEMP[Num].ID << setw(10) << TEMP[Num].SUnits << setw(8) << TEMP[Num].GPA <<endl;
				counter++ ;
				Input.ignore(10,'\n');
				getline(Input,Name);
			}
			Tot_GPA = Tot_Points / Tot_Units;
			cout <<"==================================================\n";
			cout <<"Group of "<<counter<<setw(25)<<" Students Totals" <<setw(10)<< Tot_Units << setw(10)<< Tot_GPA  << endl << endl ; 
			Output <<"==================================================\n\n";
			Output <<"Group of "<<counter<<setw(25)<<" Students Totals" <<setw(10)<< Tot_GPA << setw(10)<< Tot_GPA  << endl << endl ; 
			cout << endl << endl ;
		}
	}
	return 0;
}



Here are the functions I'm using.
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
void Process_Data(ifstream &Input, Stud temp[], PStud &list, int &Num){
	float GPA, Points, SPoints = 0, Tot_Points;
	int Units, SUnits = 0, Tot_Units;
	char Grade;
	Input >> Grade;
	while(Grade != '*')
	{
		Input >> Units;
		Points = Assign_GPA(Grade);
		Process(Units, Points, SPoints, SUnits);
		Input >> Grade;
	}
	temp[Num].SUnits += SUnits;
	temp[Num].SPoints += SPoints;
	if (temp[Num].SUnits > 0)
	{
		temp[Num].GPA = temp[Num].SPoints/temp[Num].SUnits;
		Num++;
	}
}

float Assign_GPA(char Grade)
{
	float score;
	if (Grade == 'A' || Grade == 'a')
		score = 4.0;
	else if(Grade == 'B' || Grade == 'b')
		score = 3.0;
	else if(Grade == 'C' || Grade == 'c')
		score = 2.0;
	else if(Grade == 'D' || Grade == 'd')
		score = 1.0;
	else if(Grade == 'F' || Grade == 'f')
		score = 0.0;
	else
		score = -1;
	return score;
}

void Process(int Units, float Points, float &SPoints, int &SUnits)
{
	if (Verify(Units) && Points >= 0)
	{
		SPoints += Points*Units;
		SUnits += Units;
	}

}

bool Verify(int Units)
{
	if (Units > 0 && Units <=5)
		return true;
	else
		return false;
}

bool Open_File(ifstream &Input)
{
	int counter = 0;
	string FName;
	do{
		counter++;
		Input.clear();
		cout << "Enter the input file name: ";
		getline(cin, FName);
		Input.open(FName.c_str());
	}while (Input.fail() && counter < 3);
	if (counter > 3)
	{
		cout <<"Bad file name.\nProgram Terminated.\n\n";
		return false;
	}
	return true;
}

bool Open_File2 (ofstream &Output)
{
	int counter = 0;
	string FName;
	do{
		Output.clear();
		cout << "Enter the output file name: ";
		getline(cin, FName);
		Output.open (FName.c_str());
	}while (Output.fail() && counter < 3);
	if (counter > 3)
	{
		cout << "Bad file name.\nProgram Terminated.\n\n";
		return false;
	}
	return true;
}
void Process_Data(ifstream, Stud, PStud &, int &);
Second parameter is a Stud object. No, wait...
void Process_Data(ifstream &Input, Stud temp[], PStud &list, int &Num) Second parameter is an array of Stud objects.

Pick one, and stick with it.
so i replaced
void Process_Data(ifstream, Stud, PStud &, int &);
with
void Process_Data(ifstream, Stud[], PStud &, int &);

and added [Size] to the second parameter in my int main
Process_Data(Input, TEMP[Size], Stud, Num);

but now it's telling me that my "Process Data" is wrong:
IntelliSense: no instance of overloaded function "Process_Data" matches the argument list

and I still have error c2664
:^(
Process_Data(Input, TEMP[Size], Stud, Num);

The second parameter should be an object of type Stud[]. TEMP[Size] is not such an object. TEMP is.

It's much easier to use proper C++ vectors for this sort of thing.
Thanks for your help so far, my professor didn't have time to go over vectors this semester.

Ok, so when I use
Process_Data(Input, TEMP, Stud, Num)

I no longer get c2664, but I still get
IntelliSense: no instance of overloaded function "Process_Data" matches the argument list

and now
error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

how would I make the member public?
Topic archived. No new replies allowed.