dagao said:
I have an object and want to store it in a file. Then later I can read
in the object and obtain all the info in it.
How can I do this ? Thanks a lot.
This topic is called persistence. Add a save and a restore member function
to the class. They must be intelligent enough to know what and how to save
and subsequently reproduce a working (not necessarily identical) data set. I
would suggest experimenting with increasingly difficult cases. Say
something without pointers, then a linked list and then a tree. If you save
a tree wrong you can end up with terrible performance, which gets back to my
"not necessarily identical" comment.
In the linked list, for example, you don't save the pointers, you save the
"pointees". Probably in a text file. Remeber that structs can be padded;
number of bits an int is, in general unkown, big endian/little endian etc.,
can have negative impact in the future if this is more than a short term
thing such as a student exercise.