I am writing a text-based RPG game using some OOP and polymorphism. I wanted to add a game save function to it, but I am at a dead end as to how to do this. I don't want to use a basic 'ofstream' function, but I want to make sure the player can't edit the save file. So I was thinking about serialization or something. It also needs to be efficient for performance. I am just intimidated by all the options and I don't know what to pick or use.

The only way you could possibly stop someone from modifying theor own data on their own computer is to save the game to a remote server, and even then you'd need a secure connection. Are you sure it's worth the hassle, given they could still crack your program to bypass that?

Just write your data using the standard formatting streams. You can check and edit the save game files manually that way, if only for verification, and you can let people do what they want with their own data.

Just write your data using the standard formatting streams. You can check and edit the save game files manually that way, if only for verification, and you can let people do what they want with their own data.

Yes, how would I do that? That is what I am looking for. I want to add serialization in it though.

Just write your data using the standard formatting streams. You can check and edit the save game files manually that way, if only for verification, and you can let people do what they want with their own data.

Yes, how would I do that? That is what I am looking for. I want to add serialization in it though.

I suggest you write a pair of functions std::ostream& operator<<(std::ostream&, const Game&) and std::istream& operator>>(std::istream&, Game&) where Game is you game state you want to save. Make them friends of your Game class. Do this recursively with the members of the Game class. Write unit tests to make sure (a) the output is what you expect and (2) the istream can read what the ostream writes.