最新范本,供参考!
最新范本,供参考!
最新范本,供参考!
#include <iostream>
#include <iomanip>
#include <string>
#include<>
#include<>
#include<>
#include <fstream>//输入/输出文件流类
using namespace std;
const int Maxr=100;//最多的读者
const int Maxb=100;//最多的图书
const int Maxbor=5;//每位读者最多借五本书
//读者类,实现对读者的信息的描述
class Reader
{
private:
int tag; //删除标记 1:已删 0:未删
int no; //读者编号
char name[10]; //读者姓名
int borbook[Maxbor];//所借图书
public:
Reader() {}
char *getname() {return name;} //获取姓名
int gettag() {return tag;} //获取删除标记
int getno() {return no;} //获取读者编号
void setname(char na[]) //设置姓名
{
strcpy(name,na);
}
void delbook(){ tag=1; }//设置删除标记 1:已删 0:未删
void addreader(int n,char *na)//增加读者
{
tag=0;
no=n;
strcpy(name,na);
for(int i=0;i<Maxbor;i++)
borbook[i]=0;
}
void borrowbook(int bookid)//借书操作
{
for(int i=0;i<Maxbor;i++)
{
if (borbook[i]==0)
{
borbook[i]=bookid;
最新范本,供参考!
最新范本,供参考!
最新范本,供参考!
return;
}
}
}
int retbook(int bookid)//还书操作
{
for(int i=0;i<Maxbor;i++)
{
if(borbook[i]==bookid)
{
borbook[i]=0;
return 1;
}
}
return 0;
}
void disp()//读出读者信息
{
cout << setw(5) << no <<setw(10) << name<<"借书编号:[";
for(int i=0;i<Maxbor;i++)
if(borbook[i]!=0)
cout << borbook[i] << "|";
cout << "]"<<endl;
}
int Reader::jieshu(int i)
{
return borbook[i];
}
};
//读者类库,实现建立读者的个人资料
class RDatabase
{
private:
int top; //读者记录指针
Reader read[Maxr];//读者记录
public:
RDatabase() //构造函数,[]中
{
Reader s;
top=-1;
fstream file("",ios::in);//打开一个输入文件
while (1)
{
((char *)&s,sizeof(s));
最新范本,供参考!
最新范本,供参考!
最新范本,供参考!
if (!file)break;
top++;
read[top]=s;
}
(); //关闭
}
void clear()//删除所有读者信息
{
top=-1;
}
int addreader(int
图书馆管理系统源程序 来自淘豆网www.taodocs.com转载请标明出处.