Sign in to follow this  
Jemburula

Saving Class Data to a file

Recommended Posts

Hey, Wasn't exactly sure what term to search for when researching how to do this but: I've created a class for each person in say a team and inputted all their data etc, so now I want to save the "state" I suppose of each person in the same text file such as "Team1.txt" sort of thing. That being said then I want to be able to load the data back up and reinitialize a each class. I haven't a clue where to start with converting the data or anything so if someone could point me in the right direction or some buzzwords etc it would be very much appreciated. I'm using C++ on Windows, thanks again everyone. Jemburula

Share this post


Link to post
Share on other sites
Serialization is a very nice way of saving binary data to files. Could be exactly what you're looking for. If you're looking for a more organized way of presenting it in the text file, I'd suggest looking into either XML files or a variation of config files.

Share this post


Link to post
Share on other sites
Ah thank you both very much, I followed your link on serialization Rob and just whipped up a quick test and it worked like a charm. I would of tried tinyxml because I've heard of it quite alot, but I'm pretty new to using all new libraries etc so perhaps another time. Thanks again both of you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this