No operator matches "[]" these operands And error C2248
I'm getting No operator matches "[]" these operands
and this error that I have no clue about :\program files (x86)\microsoft visual studio 10.0\vc\include\fstream(1116): error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
Code:
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#define SIZE 20
using namespace std ;
struct Students{
ifstream Fin;
ofstream Fout;
float Units, GPA, Total_Units, Avg_GPA, Mega_Units, Cyan, Mega_Cyan, GradeK;
long ID;
string First_Name, Last_Name , name, letter, Grade;
};
void print_OList(Students List[], int size);
void print_O(Students Temp, int size);
float assign_grade(Students &Temp, int size);
void Process_List(Students List[], int size, float Cyan);
void Read_Stu(Students &Temp, ifstream &Fin, int size);
void Calc_GPA(Students &Temp) ;
int read_O(Students List[], int safe);
void Intro();
int main() {
Students List[SIZE];
string letter;
float Cyan = 0;
int size = 0, j = 0;
Intro();
size = read_O(List,SIZE);
if (letter == "O" || letter == "o")
{
read_O(List, SIZE);
Process_List(List, size, Cyan);
print_OList(List, size);
print_O(List[j], size);
}
return 0;
}
void Intro()
{
string letter, Option;
do {
cout << "'O' -- Open an existing student’s file." << endl;
cout << "'A' -- Add new person to the current list." << endl;
cout << "'R' -- Remove a person from the current list." << endl;
cout << "'P' -- Print one student’s info in the current list." <<endl;
cout << "'E' -- Edit information for 1 person." << endl;
cout << "'S' -- Search." <<endl;
cout << "'T' -- Sort the list" <<endl;
cout << "'X' -- Exit the program." <<endl;
cout << "Please choose an action or enter Z to exit the program: " << endl;
cin >> letter;
}while( Option != "z" || Option != "Z");
}
int read_O(Students List[], int safe, int size)
{
int i = 0;
ifstream Fin ;
string name ;
cout <<"Enter input file name: ";
getline(cin, name);
Fin.open(name.c_str());
if(Fin.fail())
cout << "Bad file.\n" ;
else
{
while (!Fin.eof())
{
i++;
if(i < SIZE)
Read_Stu(List[i], Fin, size);
else
{
cout <<"Array is full.\n\n";
break;
}
}
}
return i ;
}
void Read_Stu(Students &Temp, ifstream &Fin, int size)
{
getline(Fin, Temp.name) ;
Fin >> Temp.ID >> Temp.Grade ;
Fin >> Temp.Units;
assign_grade(Temp, size);
Fin.ignore(10,'\n');
}
void print_OList(Students List[], int size)
{
int j = 0;
cout << "\t" << endl;
cout << "Name" << setw(23) << "ID#" << setw(15) << "Units" << setw(15) << "GPA" << endl;
cout << "==========================================================" << endl;
}
void print_O(Students Temp, int size)
{
for (int j = 0 ; j < size ; j++)
{
cout << fixed << left << setw(23) << Temp.name << " " << setw(13) << Temp.ID << " " << setw(13) << setprecision(0) << Temp.Total_Units << " " << setprecision(2) << Temp.GPA << endl;
}
cout << "\t" << endl;
cout << "==========================================================" << endl;
cout << "Group of 6 Student's Totals " << Temp.Mega_Units << Temp.Avg_GPA << endl;
}
void Process_List(Students List[], int size, float Cyan)
{
for (int i = 0 ; i < size; i++)
Calc_GPA(List[i]);
}
void Calc_GPA(Students &Temp)
{
int i = 0;
Temp.Total_Units[i] += Temp.Units[i];
Temp.Cyan[i] += (Temp.GradeK[i] * Temp.Units[i]);
if (Temp.Total_Units[i] < 0)
{
Temp.GPA = 0;
}
else if (Temp.Total_Units > 0)
{
Temp.GPA = (Temp.Cyan)/Temp.Total_Units;
Temp.Mega_Units += Temp.Total_Units;
Temp.Mega_Cyan += (Temp.GPA * Temp.Total_Units);
Temp.Total_Units = 0;
Temp.Cyan = 0;
}
}
float assign_grade(Students &Temp, int size)
{
for(int i = 0 ; i < size ; i++)
{
while (Temp[i].Grade != "*")
{
if (Temp.Grade == "A" || Temp.Grade == "a")
Temp[i].GradeK = 4;
else if (Temp.Grade == "B" || Temp.Grade == "b")
Temp.GradeK = 3;
else if (Temp.Grade == "C" || Temp.Grade == "c")
Temp.GradeK = 2;
else if (Temp.Grade == "D" || Temp.Grade == "d")
Temp.GradeK = 1;
else if (Temp.Grade == "F" || Temp.Grade == "f")
Temp.GradeK = 0;
if (!(Temp.Grade == "A" || Temp.Grade == "a" || Temp.Grade == "B" || Temp.Grade == "b" || Temp.Grade == "C" || Temp.Grade == "c" || Temp.Grade == "D" || Temp.Grade == "d" || Temp.Grade == "F" || Temp.Grade == "f"))
{
Temp.GradeK = 0;
Temp.Units = 0;
}
else if (Temp.Units < 0 || Temp.Units > 5)
{
Temp.Units = 0;
}
}
}
}
//'O' (END)//