I am trying to this homework for my c++ class and I have been working on it for a few hours now and am not making any progress. I've done a bunch of searches on my issues and nothing is really working. I've come here hoping to solve my issue.
I have a file called "hw2data.txt" with 25 lines of information and i'm trying to simply output it to the console for now but my homework says I need to do it using an array of Student(my class name) that holds 25 objects In the main function, the program reads from the data file and calls member functions of class Student to set member variables and output the results.
I want to just be able to fully output the text in the file before going into the functions and adding them to the results.
TXT File
10001 Alice Brown 89 85 92 99 90
10004 Bob Bush 85 76 83 79 83
10010 Carl Capra 65 57 73 68 76
10012 David Lieberman 76 68 79 81 58
10034 John Menchin 100 89 95 93 88
10056 George Smith 86 78 90 80 95
10062 Elaine Sanders 85 79 90 80 95
10078 Jack Cunningham 72 78 82 97 84
10090 Susie Brown 68 85 80 84 83
10099 Marvella Garcia 86 92 88 97 98
10120 Tony Peterson 85 84 83 90 76
10129 John Jones 75 75 80 84 80
10131 Mary Evans 60 72 89 86 65
10146 Nancy Drew 78 80 75 90 85
10152 Lola Zapeta 89 81 98 89 97
10155 Duckey Donald 82 60 73 78 55
10163 Goof Goofy 89 78 75 89 56
10168 Brave Balto 100 98 93 89 92
10178 Snow Smitn 93 76 54 83 80
10184 Alice Wonderful 86 79 87 78 67
10192 Samina Akthar 85 62 78 45 60
10207 Simba Green 50 45 35 60 20
10211 Donald Egger 76 80 83 68 81
10216 Brown Deer 86 87 89 79 75
10245 Johny Jackson 96 85 91 83 79
Student Class File
#include <iostream>
#include <fstream>
#include <string>
#include "Student.h"
using namespace std;
void Student::setID(int tID)
{
ID = tID;
}
void Student::setFName(string f)
{
firstName = f;
}
void Student::setLName(string l)
{
lastName = l;
}
void Student::setScores()
{
}
int Student::getID()
{
return ID;
}
string Student::getFName()
{
return firstName;
}
string Student::getLName()
{
return lastName;
}
int Student::getWeightedTotal()
{
return 0;
}
int Student::getGrade()
{
return 0;
}
void Student::printStudent()
{
}
Student::Student()
{
ID = 0;
firstName = "";
lastName = "";
}
Student::Student(int tID, string f, string l)
{
setID(tID);
setFName(f);
setLName(l);
}
Main.cpp File
#include <iostream>
#include <fstream>
#include <string>
#include "Student.h"
using namespace std;
int main() {
Student students;
Student sa[25];
ifstream inFile;
inFile.open("hw2data.txt");
system("pause");
return 0;
}
I've tried multiple ways of getting this to work and the main error i get is "binary '>>': no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion)" Please help