Need to know how to access fstream within a class

I'm working on a project that requires me to input data from several text files using a public member function from a class, and assign a value from each function to a private data member. A class object array within the main function will then store a row of data from each of the files in one of its elements, then the cycle repeats until all of the file data (each of the files has the same number of data points) is stored in the class object.

However I'm having some problems getting this to work. I am trying to use the stream state data type ifstream to input the data from the files. Something has gone horribly wrong and I'm not sure what it is. Could someone please give me advice?

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

using namespace std;

class Student_Grade
{
	
	char SFN[12];     // Student First Name
	double MTE;       // Mid-Term Exam Grade
	double FE;        // Final Exam Grade
	double QAG;       // Average Quiz Grade
	double FG;        // Final Grade

	public:
		void getStudentData(ifstream Name, ifstream Midterm, ifstream Final, ifstream Quiz);
};

#define totalStudents 46
int main(void)
{
	int i;
	Student_Grade Grades[totalStudents];
	ifstream name("Student_data/FristName.txt");
	ifstream midterm("Student_data/MidtermExam.txt");
	ifstream final("Student_data/FinalExam.txt");
	ifstream quiz("Student_data/QuizAve.txt");

	for (i = 0; i < totalStudents; i++)
	{
		Grades[i].getStudentData(name, midterm, final, quiz);
	}
	name.close();
	midterm.close();
	final.close();
	quiz.close();
system("pause");
	return 0;
}
void Student_Grade::getStudentData(ifstream Name, ifstream Midterm, ifstream Final, ifstream Quiz)
{
	
	Name >> SFN;
	
	Midterm >> MTE;
	
	Final >> FE;
	
	Quiz >> QAG;
}
	
Topic archived. No new replies allowed.