ana*_*rex 1 c++ serialization file
我有一个看起来像这样的C++对象
class myClass
{
vector<OtherClass*> otherClassVector;
AnotherClass* anotherClassObj;
// A few other primitive types and functions
}
Run Code Online (Sandbox Code Playgroud)
将此存储到磁盘并以编程方式将其读回的最佳方法是什么?在二进制模式下使用fstream读/写是否有效?或者我应该使用boost序列化?为什么?我不要求存储的文件是人类可读的.
使用boost::serialization就是编写自己的序列化程序.如果OtherClass是具体类型(不是基础) - 通过读/写序列化很简单,对于vector - 只保存大小而不是数组(如果你的myClass没有非POD类型)然后存储元素,其中anotheClassObj指针指向...
| 归档时间: |
|
| 查看次数: |
1006 次 |
| 最近记录: |