title: C++ writing an object to a file then later reading it in?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/234724/how-to-serialize-in-c">How to serialize in c++?</a><br>
    <a href="https://stackoverflow.com/questions/1809670/how-to-implement-serialization-in-c">How to implement serialization in C++</a>  </p>
  </blockquote>
  
  
  
  <p>I've been toying around with C++ more and more these days and have only had a couple experiences with ofstream at this point.   Most of said experiences have been doing simple file output of variables and reading them back in with ifstream.  What I haven't done is anything with objects.</p>
  
  <p>Let's assume that I have an object that is being written to frequently (say a game, and the object is the character)  Every time the character is hit, the hp is re-written, every time they defeat an enemy they are gaining experience.... my basic idea is to write a simple text-based dungeon crawling game.  But how am I going to make some kind of an autosave file?? Do I just write out every attribute of my object to a file individually and then move onto bigger and better from there?  If I had to do it right now that's how I'd go about doing it, but I can't help like feeling that there's an easier way than that....</p>
  
  <p>Anyone care to help me output the contents of an entire object(and it's respective attributes) to a file?</p>