quote:
Originally posted by DJeX
Sorry Choli, I'm just starting out with C++. How would I dump the class attributes to a file?
the basic idea is that you create a metod that when called if saves all the variables to the file and another one for reading the file and setting the variables with the proper value. If you're new with C/C++, you should get used to manage files (open, close, read, write, .... them).
IMO, you have to ask yourself several questions: do you really want to save the exact status of your program or you only want to save the user settings? Think a bit about that, it's not the same and probably you do not want the first thing * (which is like pausing the execution of the program and resuming it later; quite complex because it envolves more things than just saving and loading all the status and settings)
As a summary of what Cookie said, and saying like a "geleral rule", you should use the registry to store the user settings of the program, ie: how the program behaves; and save into a file (or files) the data that the program manages: what the programs works with (user's data, documments, etc...).
*-> in case you want to save the whole status of your program: ask yourself: what differences the program in two instants of time? what may change from one moment to the next one? All that has to be measured and forms the status of the program. If you dessign the program well, all that will be in (and will be formed by) all the variables and classes of your program together with the current task that the program is doing, which should be doing nothing, because at the point where you save the status your program shouldn't be doing anything else.
--------
I know all this may seem quite complex to understand, because you're new at c++. Don't worry. First of all get used to the language and then start doing more complex things.
Let me suggest you a book: "Thinking in C++". It's a book made of 2 volumes and you can freely download from the internet (google it). I haven't read the whole book, but it seems a quite good book.