摘要: C++的类的持久化可以通过下面文章中所使用的方法来实现其原理是将对象的内容以二进制的形式保存到文件中,在要读取的时候再使用相反的过程来加载到对象中.总结起来就是可以为要进行持久化的对象,比如说配置类,添加如下的两个方法:bool Config::Save(){ofstream ofs("config.bin", ios::binary);ofs.write((char *)this, sizeof(*this));return true;}bool Config::Load(){ifstream ifs("config.bin", ios::binary 阅读全文
posted @ 2010-12-03 19:34 OYJJ 阅读(1466) 评论(0) 推荐(0) 编辑