First of all, let me say this. I just started object oriented programming in college and I am already way ahead of the subject matter being taught. Wow, that came off as cocky, I mean this is not one of those OMG my homework is due tomorrow type situations. So if possible just nudge me in the right direction instead of flat out telling me what to do. That being said here is my problem.

I have a program, that contains a class called Student. The student class stores the student's name, scores, ID number etc. I set the program up to save the student's info onto a file. The problem is when I tried to load the student's data from the file (now is a good time to mention that is an array of students) every element in the array gets the information of the same student (the first in the file.)

I overloaded the saveStudent function so it would accept all the student data. I am planning on trying to overload the loadStudent function by opening the ifstream in the first loadStudent function and setting up infile.close () to trigger after the last student is loaded in the second function. Would that work or will the infile close after the function closes? Is there a better way to approach this?

Sorry for being long winded, just want to make sure enough program background is there to get an opinion on what to do.

Thanks in advance

forget i said anything. I totally forgot that I could pass streams through a function parameter list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.