好吧,你可以手动完成.如果没有,最简单的方法是使用boost.serialization,它支持所有标准容器:
std::ofstream ofs("output_file");
// create class instance
std::map<int,string> whatever;
// populate map.
// save data to archive
{
boost::archive::text_oarchive oa(ofs);
// write map instance to archive
oa << whatever;
// archive and stream closed when destructors are called
}
Run Code Online (Sandbox Code Playgroud)
您可以看到反向如何工作(从存档读取),以及您还可以使用二进制存档.(您还需要一堆包含,但您可以从文档中获取这些内容.)
| 归档时间: |
|
| 查看次数: |
4239 次 |
| 最近记录: |