图书馆管理系统C++代码HT.doc

  1. 1、本文档共13页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
图书馆管理系统C代码HT

// tushuguanli.cpp : Defines the entry point for the console application. // #include string//字符串头文件 #include fstream//文件头文件 #include iostream//是指标准库中输入输出流的头文件, cout就定义在这个头文件里 using namespace std;//使用名字空间std const int BMAX=50; //书最多个数 //图书管理模块 //图书类 class book { public: int no; //图书编号 char name[20]; //图书名称 int b_flag; //1为在架,2为借出 int b_del; //1为存在, 2为删除 public : book(){} //构造函数 void setno(int n) { no=n; //图书编号取值 } int getno() { return no; //返回图书编号值 } void setname(char na[]) { strcpy(name, na); //字符串复制 } char* getname() { return name; //返回图书名称 } void borbook() { b_flag=2; //借书标志 } void delbook() { b_del=2; //删除标志 } void addbook(int no,char na[]) //增加图书功能 { setno(no); setname(na); b_flag=1; b_del=1; } } ; //图书数据库类 class bdatabase { public: book btarray[BMAX]; //图书集合 int top; public: bdatabase() { book b; top=-1; fstream file(book.txt,ios::in); //打开文件 while (1) { file.read((char *)b,sizeof(b)); if (!file) break; top++; btarray[top] = b; } file.close(); //关闭文件 } ~bdatabase() //析构函数, 将btarray[]写到book.txt文件中 { fstream file(book.txt,ios::out); for (int i=0;i=top;i++) { if (btarray[i].b_del==1) file.write((char *)btarray[i],sizeof(btarray[i])); } file.close(); } void addbooks() //往图书数据库中加图书 { book bk; int no; char bname[20]; cout请输入书号: ; cinno; coutendl请输入书名: ; cinbname; coutendl; bk.b_flag=1; bk.addbook(no, bname); top++; btarray[top]=bk; return; } int findbooks(int suffix) //查找图书,这个函数用于借书这书操作,suffix是数组下标 { int no; cout请输入书号: ; cinno; for(int i=0; i=top

文档评论(0)

153****9595 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档