I'm having some trouble with a programming project. I want to get information from a .txt document, and store the information in an array of class objects. For each line of the .txt document, I want a new class object to be created.
So if there was
"10 Mark 9/24/1988 accounts manager
9 Jenny 8/6/1983 shipping assistant"
in the .txt, the first line would be stored in the variables of the first object at uArray[0] and the second line would be stored in the variables of uArray[1].
I've created a class "users" with five variables.
int iD;
string name, birth, sSN, dept, position;
This is what I have, I know it is way, way off, but I can't get it right..
{
ifstream myFile;
users uArray[100];
myFile.open("users.txt")
while(!myFile.eof())
{
myFile >> uArray.users.iD >> uArray.users.name >> uArray.users.sSN ...(ect);
}
}
Should I create a function to call that will sort the information or is there an easier way? I'm stuck... Sorry for the beginner's questions...