管理系统序列化以及写入写出问题
22222.rar
(79.24 KB)
新手写的教师住房管理系统,老师要求存盘数据,DOC代码里的序列化函数好像有问题,,但怎么都找不到问题出在哪。。调试中又一次调试好了,但是生成列表时程序出错,好像是写入写出也有问题,,菜鸟想破脑袋也不知道怎么回事。,。求大神指导,,用户名密码都是admin
CMy22222Doc::CMy22222Doc() { // TODO: add one-time construction code here CFile file; if(!file.Open("data.txt",CFile::modeRead)) { return; } //这段代码注释掉,因为已经Open了,所以不需要再次Open了 /* else { file.Open("data.txt",CFile::modeRead); } */ CArchive Ar(&file,CArchive::load); Serialize(Ar); }
void Serialize(CArchive &ar) { if(ar.IsStoring()) { ar<<bornf; //注意:是<< ar<<bornm; ar<<borny; ar<<hy; ar<<level; ar<<name; ar<<score; ar<<sex; ar<<sq; ar<<square; ar<<workf; ar<<workm; ar<<worky; ar<<xl; ar<<xlf; ar<<zc; ar<<zcf; } else { ar>>bornf; //注意:是>> ar>>bornm; ar>>borny; ar>>hy; ar>>level; ar>>name; ar>>score; ar>>sex; ar>>sq; ar>>square; ar>>workf; ar>>workm; ar>>worky; ar>>xl; ar>>xlf; ar>>zc; ar>>zcf; } }