I am trying to write a code, where I need to store the intermediate results in a file for later retrieval. For example, I need to store all the values in an 3D Array in a file, with the dimensions and later retrieve the array for later use. Is there a way I could preserve the object for later use, by storing in a file. For Example….
class Obj {
};
Obj ***array;
//declare and initialize the 3d Array.
.
.
.
//do some modifications
.
.
.
.
write the object in the file
ofstream file;
file.open("some_file.txt");
file<<array;
.
.
.
end program.
reopen another program
ifstream file;
file.open("some_file.txt");
Obj *another_array;
file>>another_array;
Dont look too much details in the code snippet.
its just an example..
Thanks…
I think there is another think called binary serialization…
It’s indeed called serialization. You’re best off not reinventing the wheel. Use Boost.Serialization instead.