欢迎来到天天文库
浏览记录
ID:26823923
大小:83.50 KB
页数:11页
时间:2018-11-29
《图书管理系统85707》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、这个由于你给的分太少,估计每人会给你做的。我给你一个做参照吧,基本功能都已经实现了,并且在VC6上已经编译运行确认:#include#include#include#include//输入/输出文件流类usingnamespacestd;constintMaxr=100;//最多的读者constintMaxb=100;//最多的图书constintMaxbor=5;//每位读者最多借五本书//读者类,实现对读者的信息的描述classReader{private:inttag;//删除标记1:已删0:未删intno;//读者
2、编号charname[10];//读者姓名intborbook[Maxbor];//所借图书public:Reader(){}char*getname(){returnname;}//获取姓名intgettag(){returntag;}//获取删除标记intgetno(){returnno;}//获取读者编号voidsetname(charna[])//设置姓名{strcpy(name,na);}voiddelbook(){tag=1;}//设置删除标记1:已删0:未删voidaddreader(intn,char*na)//增加读者{tag=0;no=n;strcpy(name,na);f
3、or(inti=0;i4、<<"借书编号:[";for(inti=0;i5、";cout<<"]"<6、r*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();//关闭reader.txt}voidclear()//删除所有读者信息{top=-1;}intaddreader(intn,char*na)//添加读者时先查找是否存在{Reader*p=query(n);if(p==NULL){top++;read[top].addreader(n,na);return1;}return0;}Reader*query(intreaderid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getn7、o()==readerid&&read[i].gettag()==0){return&read[i];}returnNULL;}voiddisp()//输出所有读者信息{for(inti=0;i<=top;i++)read[i].disp();}voidreaderdata();//读者库维护~RDatabase()//析构函数,将read[]写到reader.txt文件中{fstreamfile("reader.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],size8、of(read[i]));file.close();}};voidRDatabase::readerdata(){charchoice;charrname[20];intreaderid;Reader*r;while(choice!='0'){cout<<"ttt读者维护tt1新增tt2更改tt3删除tt4查找tt5显示
4、<<"借书编号:[";for(inti=0;i5、";cout<<"]"<6、r*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();//关闭reader.txt}voidclear()//删除所有读者信息{top=-1;}intaddreader(intn,char*na)//添加读者时先查找是否存在{Reader*p=query(n);if(p==NULL){top++;read[top].addreader(n,na);return1;}return0;}Reader*query(intreaderid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getn7、o()==readerid&&read[i].gettag()==0){return&read[i];}returnNULL;}voiddisp()//输出所有读者信息{for(inti=0;i<=top;i++)read[i].disp();}voidreaderdata();//读者库维护~RDatabase()//析构函数,将read[]写到reader.txt文件中{fstreamfile("reader.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],size8、of(read[i]));file.close();}};voidRDatabase::readerdata(){charchoice;charrname[20];intreaderid;Reader*r;while(choice!='0'){cout<<"ttt读者维护tt1新增tt2更改tt3删除tt4查找tt5显示
5、";cout<<"]"<6、r*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();//关闭reader.txt}voidclear()//删除所有读者信息{top=-1;}intaddreader(intn,char*na)//添加读者时先查找是否存在{Reader*p=query(n);if(p==NULL){top++;read[top].addreader(n,na);return1;}return0;}Reader*query(intreaderid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getn7、o()==readerid&&read[i].gettag()==0){return&read[i];}returnNULL;}voiddisp()//输出所有读者信息{for(inti=0;i<=top;i++)read[i].disp();}voidreaderdata();//读者库维护~RDatabase()//析构函数,将read[]写到reader.txt文件中{fstreamfile("reader.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],size8、of(read[i]));file.close();}};voidRDatabase::readerdata(){charchoice;charrname[20];intreaderid;Reader*r;while(choice!='0'){cout<<"ttt读者维护tt1新增tt2更改tt3删除tt4查找tt5显示
6、r*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();//关闭reader.txt}voidclear()//删除所有读者信息{top=-1;}intaddreader(intn,char*na)//添加读者时先查找是否存在{Reader*p=query(n);if(p==NULL){top++;read[top].addreader(n,na);return1;}return0;}Reader*query(intreaderid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getn
7、o()==readerid&&read[i].gettag()==0){return&read[i];}returnNULL;}voiddisp()//输出所有读者信息{for(inti=0;i<=top;i++)read[i].disp();}voidreaderdata();//读者库维护~RDatabase()//析构函数,将read[]写到reader.txt文件中{fstreamfile("reader.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],size
8、of(read[i]));file.close();}};voidRDatabase::readerdata(){charchoice;charrname[20];intreaderid;Reader*r;while(choice!='0'){cout<<"ttt读者维护tt1新增tt2更改tt3删除tt4查找tt5显示
此文档下载收益归作者所有