【发布时间】:2012-03-26 00:57:13
【问题描述】:
我正在尝试编写代码,我需要将中间结果存储在文件中以供以后检索。例如,我需要将 3D 数组中的所有值连同尺寸一起存储在文件中,然后检索该数组以供以后使用。有没有办法通过存储在文件中来保留对象以供以后使用。比如……
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;
代码sn-p不要看太多细节。 这只是一个例子..
谢谢... 我觉得还有一种思路叫做二进制序列化……
【问题讨论】:
-
使用二进制序列化有多好???我在里面使用了很多指针......
-
措辞不佳,与旧问题完全相同。我建议搜索类似的主题,因为这已经回答过。
标签: c++ file serialization fstream