Hello Everyone. Im doing an assignment and is only 1 little step away from finishing it. Basically. I read a file called "players.txt" using ifstream. I read in all the info and then I put them in a function which is in another class called toString, where I print them all out in a specific way.
Now, I have a switch statement. If they choose option "2" then all players will be printed out. Then they can choose option "3" and then can add a Match date to a certain player, if they then press "2" again, you can see that the match date has been added. The only thing missing is to actually save that new info, basically the entire thing to the file.
In the class, I have a function called
void save(ofstream* out);
|
void save(ofstream* out);
|
Which does this
1 2 3 4 5 6 7 8 9 10
|
void Player::save(ofstream* out)
{
*out << firstName << endl << lastName << endl << birthYear << endl;
for (int i = 0; i < numberOfMatches; i++)
{
*out << matchDates << endl;
}
}
|
It saves everything into the *out. But I need to, from my switch statement, give it this "out". And I cant seem to figure out how.
Ive tried multiple things. One of them being this :
1 2 3 4
|
case 4:
ofstream open("player.txt");
team->save(open);
break;
|
But it says it cant convert ofstream to *ofstream. Any help would be appricaited, tell me if you need more info :) thank you!