Linux下的大实验——图书管理系统 代码超级详细

示例

图1

在这里插入图片描述

图2

在这里插入图片描述

main函数

#include <bits/stdc++.h>
#include <termios.h>
#include <unistd.h>
#include<string.h>
#include"People.h"
#include"Read_stream.h"
#include"Book.h"
#include"Bookname.h"
#include"Name.h"
#include"Publishing.h"
#include "Library.h"
using namespace std;
int getch()
{
    struct termios oldt,newt;
    int ch;
    tcgetattr( STDIN_FILENO, &oldt );//获得标准输入的终端参数,将获得的信息保存在oldt变量中
    newt = oldt;
    newt.c_lflag &= ~( ICANON | ECHO );
    tcsetattr( STDIN_FILENO, TCSANOW, &newt );
    ch = getchar();
    tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
    return ch;
}
template<class T>
void write_people(T &t,char *filename){
    ofstream out(filename,ios::app);
    out.write(reinterpret_cast<char*>(&t),sizeof(T));
	out.close();
}
void write_people1(char *filename){
    ofstream out(filename);
	out.close();
}
template <class T>
void Read_people(list<T> &l,char *filename){
    ifstream in(filename,ios::binary);
    l.clear();
    in.seekg(0,ios::end);
	int n=in.tellg();
	n/=sizeof(T);
    in.close();
    ifstream inf(filename,ios::binary);
	while(n--){
	   T t1;
       inf.read(reinterpret_cast<char*>(&t1),sizeof(T));
       l.push_back(t1);
	}
	inf.close();
}
template <class T>
int Read_Book(vector<T> &v,char *filename){
    ifstream in(filename,ios::binary);
    v.clear();
    in.seekg(0,ios::end);
	int n=in.tellg();
	n/=sizeof(T);
	int m=n;
    in.close();
    ifstream inf(filename,ios::binary);
	while(n--){
	   T t1;
       inf.read(reinterpret_cast<char*>(&t1),sizeof(T));
       v.push_back(t1);
	}
	inf.close();
	return m;
}
void user_system(int m,char *ch,list<People> l){
        if(m==1){
            int t=1,n,q;
            char a[16],b[16];
            People p;
            list<People>::iterator it;
            while(t){
            cout<<"****************************************"<<endl;
            cout<<"1.用户密码修改"<<endl;
            cout<<"2.返回主菜单"<<endl;
            cout<<"****************************************"<<endl;
            cin>>n;
            switch(n){
                case 1:
                    q=0;
                    cout<<"输入原密码:"<<endl;
                     cin>>a;
                    for(it=l.begin();it!=l.end();++it){
                        if(strcmp(it->getname(),ch)==0){
                                if(strcmp(it->getcode(),a)==0){
                                    cout<<"输入新密码:"<<endl;
                                    cin>>b;
                                    it->setcode(b);
                                    q=1;
                                    cout<<"密码修改成功!"<<endl;
                                    break;
                                }

                            else cout<<"原密码输入错误!  修改失败!"<<endl;
                        }
                    }
                    if(q){
                        write_people1("library_people12345.txt");
                         for(it=l.begin();it!=l.end();++it){
                             p.setname(it->getname());
                             p.setcode(it->getcode());
                             p.setid(it->getid());
                             write_people(p,"library_people12345.txt");
                         }
                    }
                    Read_people(l,"library_people12345.txt");
                    break;
               case 2:
                    t=0;
                    break;
                default: break;
            }
        }
        }
        if(m==3){
            int t1,n1,q1,q2,q3,id;
            char a1[16],b1[16],name[20],n[20];
            People p1,p2;
            list<People>::iterator it;
            while(t1){
            cout<<"****************************************"<<endl;
            cout<<"1.用户信息输入"<<endl;
            cout<<"2.用户信息修改"<<endl;
            cout<<"3.用户信息删除"<<endl;
            cout<<"4.用户信息显示"<<endl;
            cout<<"5.用户密码修改"<<endl;
            cout<<"6.返回主菜单"<<endl;
            cout<<"****************************************"<<endl;
            cin>>n1;
             switch(n1){
                case 1:
                     p2.seta();
                     cout<<"输入成功!"<<endl;
                     write_people(p2,"library_people12345.txt");
                     Read_people(l,"library_people12345.txt");
                    break;
                case 2:
                     q2=0;
                     cout<<"输入修改用户的姓名:"<<endl;
                     cin>>n;
                     for(it=l.begin();it!=l.end();++it){
                        if(strcmp(it->getname(),n)==0){
                                cout<<"输入新姓名:"<<endl;
                                cin>>name;
                                it->setname(name);
                                  cout<<"修改你的身份"<<endl;
                                  cout<<"1.普通读者"<<endl;
                                  cout<<"2.图书管理员"<<endl;
                                 cout<<"3.系统管理员"<<endl;
                                    cin>>id;
                                     switch(id){
                                       case 1:it->setid(1);
                                       break;
                                        case 2: it->setid(2);
                                        break;
                                          case 3: it->setid(3);
                                       break;
                                       }
                                cout<<"用户信息修改成功!"<<endl;
                                q2=1;break;
                            }
                        }
                        if(q2){
                        write_people1("library_people12345.txt");
                        for(it=l.begin();it!=l.end();++it){
                            p2.setname(it->getname());
                            p2.setcode(it->getcode());
                            p2.setid(it->getid());
                            write_people(p2,"library_people12345.txt");
                        }
                        }
                       else cout<<"没有该用户!"<<endl;
                        Read_people(l,"library_people12345.txt");
                    break;
                case 3:
                    q3=0;
                     cout<<"输入删除用户的姓名:"<<endl;
                     cin>>n;
                     for(it=l.begin();it!=l.end();++it){
                        if(strcmp(it->getname(),n)==0){
                             it->setid(0);
                             q3=1;
                             cout<<"删除成功!"<<endl;
                             break;
                        }
                     }
                     if(q3){
                          write_people1("library_people12345.txt");
                          for(it=l.begin();it!=l.end();++it){
                            if(it->getid()==0) continue;
                            p2.setname(it->getname());
                            p2.setcode(it->getcode());
                            p2.setid(it->getid());
                            write_people(p2,"library_people12345.txt");
                        }
                     }
                     else cout<<"没有该用户!"<<endl;
                      Read_people(l,"library_people12345.txt");
                    break;
                case 4:
                     for(it=l.begin();it!=l.end();++it){
                                cout<<"姓名:"<<it->getname()<<endl;
                                cout<<"密码"<<it->getcode()<<endl;
                                if((it->getid())==1) cout<<"用户类型:普通读者"<<endl;
                                else if((it->getid())==2) cout<<"用户类型:图书管理员"<<endl;
                                else cout<<"用户类型:系统管理员"<<endl;
                        }
                    break;
                case 5:
                    q1=0;
                    cout<<"输入修改用户的姓名:"<<endl;
                    cin>>n;
                    for(it=l.begin();it!=l.end();++it){
                        if(strcmp(it->getname(),n)==0){
                                cout<<"输入原密码:"<<endl;
                                cin>>a1;
                            if(strcmp(it->getcode(),a1)==0){
                                cout<<"输入新密码:"<<endl;
                                cin>>b1;
                                it->setcode(b1);
                                q1=1;
                                cout<<"密码修改成功!"<<endl;
                                break;
                            }
                            else cout<<"原密码输入错误!  修改失败!"<<endl;
                        }
                    }
                    if(q1){
                        write_people1("library_people12345.txt");
                        for(it=l.begin();it!=l.end();++it){
                        p1.setname(it->getname());
                        p1.setcode(it->getcode());
                        p1.setid(it->getid());
                        write_people(p1,"library_people12345.txt");
                        }
                    }
                    else cout<<"没有该用户!"<<endl;
                     Read_people(l,"library_people12345.txt");
                    break;
                case 6:
                    t1=0;
                    break;
                default: break;
                }
        }
        }
}
void read_system(){
     list<Read_stream> l1;
     list<Read_stream>::iterator it;
     Read_stream r1,r2,r3[100],rt;
     char a[20],b[20],c[30],d[20];
     int q,q1,q2,i,j,m,p,w;
     Read_people(l1,"libraryRead.txt");
     int n,t=1;
     while(t){
            cout<<"****************************************"<<endl;
            cout<<"1.读者信息输入"<<endl;
            cout<<"2.读者信息修改"<<endl;
            cout<<"3.读者信息删除"<<endl;
            cout<<"4.读者信息查询"<<endl;
            cout<<"5.读者信息显示"<<endl;
            cout<<"6.返回主菜单"<<endl;
            cout<<"****************************************"<<endl;
            cin>>n;
            switch(n){
            case 1:
                cout<<"输入读者号:"<<endl;
                cin>>a;
                cout<<"输入读者名:"<<endl;
                cin>>b;
                cout<<"输入读者单位:"<<endl;
                cin>>c;
                cout<<"输入读者联系方式:"<<endl;
                cin>>d;
                r1.setId(a);
                r1.setnameR(b);
                r1.sethome(c);
                r1.setnum(d);
                write_people(r1,"libraryRead.txt");
                cout<<"输入成功!"<<endl;
                Read_people(l1,"libraryRead.txt");
                  break;
            case 2:
                q=0,w=1;
                cout<<"输入修改读者的读者号:"<<endl;
                cin>>a;
                for(it=l1.begin();it!=l1.end();++it){
                    if(strcmp(it->getId(),a)==0){
                            while(w){
                                cout<<"**************************"<<endl;
                                cout<<"*1.修改的读者号"<<endl;
                                cout<<"*2.修改的读者名"<<endl;
                                cout<<"*3.修改的读者单位"<<endl;
                                cout<<"*4.修改的读者联系方式"<<endl;
                                cout<<"*5.退出!"<<endl;
                                cout<<"**************************"<<endl;
                                cin>>p;
                                switch(p){
                                case 1:
                                     cout<<"输入修改的读者号:"<<endl;
                                     cin>>a;
                                     it->setId(a);
                                     cout<<"修改成功!"<<endl;
                                     q=1;
                                     break;
                                case 2:
                                    cout<<"输入修改的读者名:"<<endl;
                                    cin>>b;
                                    it->setnameR(b);
                                    cout<<"修改成功!"<<endl;
                                    q=1;
                                    break;
                                case 3:
                                    cout<<"输入修改的读者单位:"<<endl;
                                    cin>>c;
                                    it->sethome(c);
                                    cout<<"修改成功!"<<endl;
                                    q=1;
                                    break;
                                case 4:
                                    cout<<"输入修改的读者联系方式:"<<endl;
                                    cin>>d;
                                    it->setnum(d);
                                    cout<<"修改成功!"<<endl;
                                    q=1;
                                    break;
                                case 5:
                                    w=0;
                                    break;
                                default: break;
                                 }
                            }

                    }
                    if(q) break;
                }
                     if(q){
                        write_people1("libraryRead.txt");
                        for(it=l1.begin();it!=l1.end();++it){
                            r2.setId(it->getId());
                            r2.setnameR(it->getnameR());
                            r2.sethome(it->gethome());
                            r2.setnum(it->getnum());
                            write_people(r2,"libraryRead.txt");
                        }
                        }
                     else cout<<"没有该读者!"<<endl;
                 Read_people(l1,"libraryRead.txt");
                break;
            case 3:
                q1=0;
                cout<<"输入删除读者的读者号:"<<endl;
                cin>>a;
                for(it=l1.begin();it!=l1.end();++it){
                    if(strcmp(it->getId(),a)==0){
                        it->setId("0");
                        q1=1;
                        cout<<"删除成功!"<<endl;
                    }
                }
                if(q1){
                     write_people1("libraryRead.txt");
                        for(it=l1.begin();it!=l1.end();++it){
                            if(strcmp(it->getId(),"0")==0) continue;
                            r2.setId(it->getId());
                            r2.setnameR(it->getnameR());
                            r2.sethome(it->gethome());
                            r2.setnum(it->getnum());
                            write_people(r2,"libraryRead.txt");
                        }
                }
                else cout<<"没有该读者!"<<endl;
                Read_people(l1,"libraryRead.txt");
                break;
            case 4:
                q2=0;
                cout<<"输入显示读者的读者号:"<<endl;
                cin>>a;
                for(it=l1.begin();it!=l1.end();++it){
                    if(strcmp(it->getId(),a)==0){
                        cout<<"读者号:"<<it->getId()<<endl;
                        cout<<"读者名:"<<it->getnameR()<<endl;
                        cout<<"单位:"<<it->gethome()<<endl;
                        cout<<"联系方式:"<<it->getnum()<<endl;
                        cout<<"已借书:"<<it->getloed()<<endl;
                        q2=1;
                        break;
                    }
                }
                if(q2==0) cout<<"没有该读者!"<<endl;
                break;
            case 5:
                m=0;
                for(it=l1.begin();it!=l1.end();++it){
                        r3[m].setId(it->getId());
                        r3[m].setnameR(it->getnameR());
                        r3[m].sethome(it->gethome());
                        r3[m].setnum(it->getnum());
                        r3[m].setloed(it->getloed());
                        m++;
                }
                for(i=0;i<m-1;i++){
                    for(j=i+1;j<m;j++){
                        if(r3[j].getnameR()>r3[i].getnameR()){
                            rt=r3[i];
                            r3[i]=r3[j];
                            r3[j]=rt;
                        }
                    }
                }
                for(i=0;i<m;i++){
                        cout<<"读者号:"<<r3[i].getId()<<endl;
                        cout<<"读者名:"<<r3[i].getnameR()<<endl;
                        cout<<"单位:"<<r3[i].gethome()<<endl;
                        cout<<"联系方式:"<<r3[i].getnum()<<endl;
                        cout<<"已借书:"<<r3[i].getloed()<<endl;
                }
                break;
            case 6:
                t=0;
                break;
            default: break;
            }
     }
}
void book_system(int m){
    int t=1,n,q,w,p1,p2,p3,p,n1,t1,q1,z,q2,q3,n2,f,t2,t3;
    Book b1;
    Bookname bn1;
    Name N1;
    Publishing Pu1;
    int man,s;
    char a[30],b[20],c[50];
    vector<Book> v1,V1;
    vector<Book>::iterator it,it4;
    vector<Bookname> v2,V2;
    vector<Bookname>::iterator it1;
    vector<Name> v3,V3;
    vector<Name>::iterator it2;
    vector<Publishing> v4,V4;
    vector<Publishing>::iterator it3;
    vector<Library> v5;
    vector<Library>::iterator it5;
    while(t){
        cout<<"********************"<<endl;
        cout<<"1.图书信息输入"<<endl;
        cout<<"2.图书信息修改"<<endl;
        cout<<"3.图书信息查询"<<endl;
        cout<<"4.汇总统计"<<endl;
        cout<<"5.返回主菜单"<<endl;
        cout<<"********************"<<endl;
        cin>>n;
        switch(n){
        case 1:
            q=0,p1=0,p2=0,p3=0,p=0,w=1,q1=0,q2=0,q3=0;
            w=Read_Book(v1,"Book.txt")+1;
            z=Read_Book(v2,"Bookname.txt");
            z=Read_Book(v3,"Name.txt");
            z=Read_Book(v4,"Publish.txt");
            if(m==1) cout<<"不能访问该功能!"<<endl;
            else{
                cout<<"输入书号:"<<endl;
                cin>>man;
                cout<<"输入书名:"<<endl;
                cin>>a;
                cout<<"输入作者:"<<endl;
                cin>>b;
                cout<<"输入出版社:"<<endl;
                cin>>c;
                cout<<"输入藏书量:"<<endl;
                cin>>s;
                for(it=v1.begin();it!=v1.end();++it){
                    if(it->getnum()==man){
                        it->setsum(it->getsum()+s);
                        q=1;
                        break;
                    }
                }
                for(it=v1.begin();it!=v1.end();++it){
                    p++;
                    if(strcmp(it->getnameb(),a)==0){
                        p1=p;
                    }
                    if(strcmp(it->getname(),b)==0){
                        p2=p;
                    }
                    if(strcmp(it->getp(),c)==0){
                        p3=p;
                    }
                }
                if(q==1){
                    write_people1("Book.txt");
                    for(it=v1.begin();it!=v1.end();++it){
                            b1.setm(it->getmanger());
                            b1.setnum(it->getnum());
                            b1.setnameb(it->getnameb());
                            b1.setname(it->getname());
                            b1.setp(it->getp());
                            b1.setsum(it->getsum());
                            b1.setloan(it->getloan());
                            b1.seta(it->geta());
                            b1.setb(it->getb());
                            b1.setc(it->getc());
                            write_people(b1,"Book.txt");
                    }
                }
                if(q==0){
                    b1.setm(w);
                    b1.setnum(man);
                    b1.setnameb(a);
                    b1.setname(b);
                    b1.setp(c);
                    b1.setsum(s);
                    b1.seta(p1);
                    b1.setb(p2);
                    b1.setc(p3);
                    write_people(b1,"Book.txt");
                }
                if(q!=1){
                     z=Read_Book(v1,"Book.txt");
                for(it1=v2.begin();it1!=v2.end();++it1){
                    if(strcmp(it1->getname(),a)==0){
                        q1=1;
                         for(it=v1.begin();it!=v1.end();++it){
                            if(strcmp(it->getnameb(),a)==0){
                                it1->setn(it->getmanger());
                            }
                        }
                        it1->setsum(it1->getsum()+1);
                    }
                }
                if(q1==1){
                    write_people1("Bookname.txt");
                    for(it1=v2.begin();it1!=v2.end();++it1){
                        bn1.setname(it1->getname());
                        bn1.setn(it1->getn());
                        bn1.setsum(it1->getsum());
                        write_people(bn1,"Bookname.txt");
                    }
                }
                if(q1==0){
                    bn1.setname(a);
                     for(it=v1.begin();it!=v1.end();++it){
                            if(strcmp(it->getnameb(),a)==0){
                               bn1.setn(it->getmanger());
                            }
                    }
                    bn1.setsum(1);
                    write_people(bn1,"Bookname.txt");
                }
                 for(it2=v3.begin();it2!=v3.end();++it2){
                    if(strcmp(it2->getname(),b)==0){
                        q2=1;
                         for(it=v1.begin();it!=v1.end();++it){
                            if(strcmp(it->getname(),b)==0){
                                it2->setn(it->getmanger());
                            }
                        }
                        it2->setsum(it2->getsum()+1);
                    }
                }
                if(q2==1){
                    write_people1("Name.txt");
                    for(it2=v3.begin();it2!=v3.end();++it2){
                        N1.setname(it2->getname());
                        N1.setn(it2->getn());
                        N1.setsum(it2->getsum());
                        write_people(N1,"Name.txt");
                    }
                }
                if(q2==0){
                    N1.setname(b);
                     for(it=v1.begin();it!=v1.end();++it){
                            if(strcmp(it->getname(),b)==0){
                               N1.setn(it->getmanger());
                            }
                    }
                    N1.setsum(1);
                    write_people(N1,"Name.txt");
                }
                for(it3=v4.begin();it3!=v4.end();++it3){
                    if(strcmp(it3->getname(),c)==0){
                        q3=1;
                        for(it=v1.begin();it!=v1.end();++it){
                            if(strcmp(it->getp(),c)==0){
                                it3->setn(it->getmanger());
                            }
                        }
                        it3->setsum(it3->getsum()+1);
                    }
                }
                if(q3==1){
                    write_people1("Publish.txt");
                    for(it3=v4.begin();it3!=v4.end();++it3){
                        Pu1.setname(it3->getname());
                        Pu1.setn(it3->getn());
                        Pu1.setsum(it3->getsum());
                        write_people(Pu1,"Publish.txt");
                    }
                }
                if(q3==0){
                     Pu1.setname(c);
                     for(it=v1.begin();it!=v1.end();++it){
                            if(strcmp(it->getp(),c)==0){
                               Pu1.setn(it->getmanger());
                            }
                    }
                    Pu1.setsum(1);
                    write_people(Pu1,"Publish.txt");
                }
                }
                cout<<"输入成功!"<<endl;
            }
            break;
        case 2:
            q=0,p1=0,p2=0,p3=0,p=0,w=1,q1=0,q2=0,q3=0,z,t3=0;
            if(m==1) cout<<"不能访问该功能!"<<endl;
            else{
                    w=Read_Book(v1,"Book.txt");
                    cout<<"输入需要修改图书的书号:"<<endl;
                    cin>>man;
                    for(it=v1.begin();it!=v1.end();++it){
                        if(it->getnum()==man){
                            t3=1;
                            cout<<"**************"<<endl;
                            cout<<"1.图书号修改"<<endl;
                            cout<<"2.图书名修改"<<endl;
                            cout<<"3.作者修改"<<endl;
                            cout<<"4.出版社修改"<<endl;
                            cout<<"**************"<<endl;
                            cin>>n2;
                            switch(n2){
                            case 1:
                                cout<<"输入修改后的书号:"<<endl;
                                cin>>man;
                                it->setnum(man);
                                break;
                            case 2:
                                cout<<"输入修改后的书名:"<<endl;
                                cin>>a;
                                it->setnameb(a);
                                break;
                            case 3:
                                cout<<"输入修改后的作者:"<<endl;
                                cin>>b;
                                it->setname(b);
                                break;
                            case 4:
                                cout<<"输入修改后的出版社:"<<endl;
                                cin>>c;
                                it->setp(c);
                                break;
                            }
                            break;
                        }
                    }
                    write_people1("Book.txt");
                    write_people1("Bookname.txt");
                    write_people1("Name.txt");
                    write_people1("Publish.txt");
                    for(it=v1.begin();it!=v1.end();++it){
                        q=0,p1=0,p2=0,p3=0,p=0,q1=0,q2=0,q3=0;
                        Read_Book(V1,"Book.txt");
                        z=Read_Book(V2,"Bookname.txt");
                        z=Read_Book(V3,"Name.txt");
                        z=Read_Book(V4,"Publish.txt");
                        w=it->getmanger();
                        man=it->getnum();
                        strcpy(a,it->getnameb());
                        strcpy(b,it->getname());
                        strcpy(c,it->getp());
                        s=it->getsum();
                        z=it->getloan();
                        for(it4=V1.begin();it4!=V1.end();++it4){
                            if(it4->getnum()==man){
                            it4->setsum(it4->getsum()+s);
                            q=1;
                            break;
                            }
                        }
                        for(it4=V1.begin();it4!=V1.end();++it4){
                                p++;
                            if(strcmp(it4->getnameb(),a)==0){
                                p1=p;
                            }
                            if(strcmp(it4->getname(),b)==0){
                                p2=p;
                            }
                            if(strcmp(it4->getp(),c)==0){
                                p3=p;
                            }
                        }
                        if(q==1){
                            write_people1("Book.txt");
                            for(it4=V1.begin();it4!=V1.end();++it4){
                                    b1.setm(it4->getmanger());
                                    b1.setnum(it4->getnum());
                                    b1.setnameb(it4->getnameb());
                                    b1.setname(it4->getname());
                                    b1.setp(it4->getp());
                                    b1.setsum(it4->getsum());
                                    b1.setloan(it4->getloan());
                                    b1.seta(it4->geta());
                                    b1.setb(it4->getb());
                                    b1.setc(it4->getc());
                                    write_people(b1,"Book.txt");
                            }
                        }
                        if(q==0){
                            b1.setm(w);
                            b1.setnum(man);
                            b1.setnameb(a);
                            b1.setname(b);
                            b1.setp(c);
                            b1.setsum(s);
                            b1.setloan(z);
                            b1.seta(p1);
                            b1.setb(p2);
                            b1.setc(p3);
                            write_people(b1,"Book.txt");
                        }
                        if(q!=1){
                            z=Read_Book(V1,"Book.txt");
                            for(it1=V2.begin();it1!=V2.end();++it1){
                            if(strcmp(it1->getname(),a)==0){
                                q1=1;
                                for(it4=V1.begin();it4!=V1.end();++it4){
                                    if(strcmp(it4->getnameb(),a)==0){
                                        it1->setn(it4->getmanger());
                                    }
                                }
                                it1->setsum(it1->getsum()+1);
                            }
                        }
                        if(q1==1){
                            write_people1("Bookname.txt");
                            for(it1=V2.begin();it1!=V2.end();++it1){
                                 bn1.setname(it1->getname());
                                 bn1.setn(it1->getn());
                                 bn1.setsum(it1->getsum());
                                 write_people(bn1,"Bookname.txt");
                            }
                         }
                        if(q1==0){
                            bn1.setname(a);
                             for(it4=V1.begin();it4!=V1.end();++it4){
                                    if(strcmp(it4->getnameb(),a)==0){
                                       bn1.setn(it4->getmanger());
                                    }
                            }
                            bn1.setsum(1);
                            write_people(bn1,"Bookname.txt");
                        }
                         for(it2=V3.begin();it2!=V3.end();++it2){
                    if(strcmp(it2->getname(),b)==0){
                        q2=1;
                         for(it4=V1.begin();it4!=V1.end();++it4){
                            if(strcmp(it4->getname(),b)==0){
                                it2->setn(it4->getmanger());
                            }
                        }
                        it2->setsum(it2->getsum()+1);
                    }
                }
                if(q2==1){
                    write_people1("Name.txt");
                    for(it2=V3.begin();it2!=V3.end();++it2){
                        N1.setname(it2->getname());
                        N1.setn(it2->getn());
                        N1.setsum(it2->getsum());
                        write_people(N1,"Name.txt");
                    }
                }
                if(q2==0){
                    N1.setname(b);
                     for(it4=V1.begin();it4!=V1.end();++it4){
                            if(strcmp(it4->getname(),b)==0){
                               N1.setn(it4->getmanger());
                            }
                    }
                    N1.setsum(1);
                    write_people(N1,"Name.txt");
                }
                 for(it3=V4.begin();it3!=V4.end();++it3){
                    if(strcmp(it3->getname(),c)==0){
                        q3=1;
                        for(it4=V1.begin();it4!=V1.end();++it4){
                            if(strcmp(it4->getp(),c)==0){
                                it3->setn(it4->getmanger());
                            }
                        }
                        it3->setsum(it3->getsum()+1);
                    }
                }
                if(q3==1){
                    write_people1("Publish.txt");
                    for(it3=V4.begin();it3!=V4.end();++it3){
                        Pu1.setname(it3->getname());
                        Pu1.setn(it3->getn());
                        Pu1.setsum(it3->getsum());
                        write_people(Pu1,"Publish.txt");
                    }
                }
                if(q3==0){
                     Pu1.setname(c);
                     for(it4=V1.begin();it4!=V1.end();++it4){
                            if(strcmp(it4->getp(),c)==0){
                               Pu1.setn(it4->getmanger());
                            }
                    }
                    Pu1.setsum(1);
                    write_people(Pu1,"Publish.txt");
                }
                    }
                }
            if(t3) cout<<"修改成功!"<<endl;
            }
            break;
        case 3:
            t1=0;
            Read_Book(V1,"Book.txt");
            z=Read_Book(V2,"Bookname.txt");
            z=Read_Book(V3,"Name.txt");
            z=Read_Book(V4,"Publish.txt");
            cout<<"************************"<<endl;
            cout<<"**1.根据书号查询"<<endl;
            cout<<"**2.根据书名查询"<<endl;
            cout<<"**3.根据作者查询"<<endl;
            cout<<"**4.根据出版社查询"<<endl;
            cout<<"************************"<<endl;
            cin>>n1;
            switch(n1){
            case 1:
                cout<<"输入查询的书名:"<<endl;
                cin>>man;
                for(it=v1.begin();it!=v1.end();++it){
                    if(it->getnum()==man){
                            t1=1;
                              cout<<"****************************************************************************"<<endl;
                        cout<<it->getmanger()<<"  "<<it->getnum()<<"  "<<it->getnameb()<<"  "<<it->getname()<<"  "<<it->getp()<<"  "<<it->getsum()<<"  "<<it->getloan()<<"  "<<it->geta()<<"  "
                        <<it->getb()<<"  "<<it->getc()<<endl;
                          cout<<"****************************************************************************"<<endl;
                    }
                }
                if(t1==0) cout<<"查无此信息!"<<endl;
                break;
            case 2:
                cout<<"输入查询的书名:"<<endl;
                cin>>a;
                for(it1=V2.begin();it1!=V2.end();++it1){
                    if(strcmp(it1->getname(),a)==0){
                        t1=1;
                        z=it1->getn()-1;
                        cout<<"****************************************************************************"<<endl;
                        while(1){
                        cout<<"记录号:"<<V1[z].getmanger()<<"书号:"<<V1[z].getnum()<<"书名:"<<V1[z].getnameb()<<"作者:"<<V1[z].getname()<<"出版社:"<<V1[z].getp()<<"藏书量:"<<V1[z].getsum()<<"借出数:"<<V1[z].getloan()<<endl;
                        if(V1[z].geta()==0) break;
                        z=V1[z].geta()-1;
                        }
                        cout<<"****************************************************************************"<<endl;
                         break;
                    }
                }
                if(t1==0) cout<<"查无此信息!"<<endl;
                break;
            case 3:
                cout<<"输入查询的作者:"<<endl;
                cin>>b;
                for(it2=V3.begin();it2!=V3.end();++it2){
                    if(strcmp(it2->getname(),b)==0){
                        t1=1;
                        z=it2->getn()-1;
                        cout<<"****************************************************************************"<<endl;
                        while(1){
                        cout<<"记录号:"<<V1[z].getmanger()<<"书号:"<<V1[z].getnum()<<"书名:"<<V1[z].getnameb()<<"作者:"<<V1[z].getname()<<"出版社:"<<V1[z].getp()<<"藏书量:"<<V1[z].getsum()<<"借出数:"<<V1[z].getloan()<<endl;
                        if(V1[z].getb()==0) break;
                        z=V1[z].getb()-1;
                        }
                        cout<<"****************************************************************************"<<endl;
                         break;
                    }
                }
                if(t1==0) cout<<"查无此信息!"<<endl;
                break;
            case 4:
                cout<<"输入查询的出版社:"<<endl;
                cin>>c;
                for(it3=V4.begin();it3!=V4.end();++it3){
                    if(strcmp(it3->getname(),c)==0){
                         t1=1;
                        z=it3->getn()-1;
                        cout<<"****************************************************************************"<<endl;
                        while(1){
                           cout<<"记录号:"<<V1[z].getmanger()<<"书号:"<<V1[z].getnum()<<"书名:"<<V1[z].getnameb()<<"作者:"<<V1[z].getname()<<"出版社:"<<V1[z].getp()<<"藏书量:"<<V1[z].getsum()<<"借出数:"<<V1[z].getloan()<<endl;
                           if(V1[z].getc()==0) break;
                           z=V1[z].getc()-1;
                        }
                        cout<<"****************************************************************************"<<endl;
                         break;
                    }
                }
                if(t1==0) cout<<"查无此信息!"<<endl;
                break;
            }
            break;
        case 4:
            w=Read_Book(v1,"Book.txt")+1;
            z=Read_Book(v2,"Bookname.txt");
            z=Read_Book(v3,"Name.txt");
            z=Read_Book(v4,"Publish.txt");
            z=Read_Book(v5,"library.txt");
            cout<<"*********************************图书总索引*********************************"<<endl;
            cout<<"记录号  书号      书名        作者        出版社    藏书量   借出数  指针1   指针2   指针3"<<endl;
            for(it=v1.begin();it!=v1.end();++it){
                    if(strcmp(it->getnameb(),"数据库")==0){
                        cout<<setw(8)<<setfill(' ')<<left<<it->getmanger()<<setw(8)<<setfill(' ')<<left<<it->getnum()<<setw(17)<<setfill(' ')<<left<<it->getnameb()<<setw(12)<<setfill(' ')<<left<<it->getname()<<setw(18)<<setfill(' ')<<left<<it->getp()<<setw(8)<<setfill(' ')<<left<<it->getsum()<<setw(8)<<setfill(' ')<<left<<it->getloan()<<setw(8)<<setfill(' ')<<left<<it->geta()<<setw(8)<<setfill(' ')<<left
                        <<it->getb()<<setw(8)<<setfill(' ')<<left<<it->getc()<<endl;
                    }
                    else{
                        cout<<setw(8)<<setfill(' ')<<left<<it->getmanger()<<setw(8)<<setfill(' ')<<left<<it->getnum()<<setw(18)<<setfill(' ')<<left<<it->getnameb()<<setw(12)<<setfill(' ')<<left<<it->getname()<<setw(18)<<setfill(' ')<<left<<it->getp()<<setw(8)<<setfill(' ')<<left<<it->getsum()<<setw(8)<<setfill(' ')<<left<<it->getloan()<<setw(8)<<setfill(' ')<<left<<it->geta()<<setw(8)<<setfill(' ')<<left
                        <<it->getb()<<setw(8)<<setfill(' ')<<left<<it->getc()<<endl;
                    }
            }
            cout<<"****************************************************************************"<<endl;
            if(m!=1){
                cout<<"***************书名索引*************"<<endl;
            for(it1=v2.begin();it1!=v2.end();++it1){
                cout<<it1->getname()<<"  "<<it1->getn()<<"  "<<it1->getsum()<<endl;
            }
             cout<<"************************************"<<endl;
            cout<<"***************作者索引*************"<<endl;
            for(it2=v3.begin();it2!=v3.end();++it2){
                cout<<it2->getname()<<"  "<<it2->getn()<<"  "<<it2->getsum()<<endl;
            }
             cout<<"************************************"<<endl;
            cout<<"***************出版社索引***********"<<endl;
            for(it3=v4.begin();it3!=v4.end();++it3){
                cout<<it3->getname()<<"  "<<it3->getn()<<"  "<<it3->getsum()<<endl;
            }
            cout<<"************************************"<<endl;
            cout<<"*****************************借书与还书人员统计*****************************"<<endl;
            for(it5=v5.begin();it5!=v5.end();++it5){
                cout<<"读者号:"<<it5->getname()<<"借取书号:"<<it5->getbook()<<"借取数量:"<<it5->getsum()<<"借取时间:"<<it5->getloantime()<<"还书时间:"<<it5->getloedtime()<<endl;

            }
            cout<<"****************************************************************************"<<endl;
            }
            break;
        case 5:
            t=0;
            break;
        default: break;
        }
    }
}
void book2_stream(){
    int t=1,n,m,w,q,q1,q2,sum;
    char a[20],b[20];
    Library l;
    Book b1;
    list<Read_stream> l1;
    list<Read_stream>::iterator it;
    Read_stream r1;
    vector<Book> v1;
    vector<Book>::iterator it1;
    vector<Library> v2;
    vector<Library>::iterator it2;
    while(t){
        cout<<"********************************"<<endl;
        cout<<"1.借书处理"<<endl;
        cout<<"2.还书处理"<<endl;
        cout<<"3.返回主菜单"<<endl;
        cout<<"********************************"<<endl;
    cin>>n;
    switch(n){
    case 1:
        q=0,q1=0,q2=0;
        Read_people(l1,"libraryRead.txt");
        w=Read_Book(v1,"Book.txt");
        cout<<"输入借书读者的读者号:"<<endl;
        cin>>a;
        for(it=l1.begin();it!=l1.end();++it){
            if(strcmp(it->getId(),a)==0){
                q=1;
                cout<<"输入读者借取书的书号:"<<endl;
                cin>>m;
                for(it1=v1.begin();it1!=v1.end();++it1){
                    if(it1->getnum()==m){
                        q1=1;
                        cout<<"输入借取数量!"<<endl;
                        cin>>sum;
                        if(it1->getsum()>=sum){
                            q2=1;
                            it1->setsum(it1->getsum()-sum);
                            it1->setloan(sum+it1->getloan());
                            it->setloed(it->getloed()+sum);
                            cout<<"输入借书时间:"<<endl;
                            cin>>b;
                            l.setname(a);
                            l.setbook(m);
                            l.setsum(sum);
                            l.setloantime(b);
                            write_people(l,"library.txt");
                        }
                        if(q2==0) cout<<"借取数量超额!"<<endl;
                        break;
                    }
                }
                if(q1==0) cout<<"没有书号为"<<m<<"的书!"<<endl;
                break;
            }
        }
        if(q==0) cout<<"没有该读者!"<<endl;
        if(q==1&&q1==1&&q2==1){
                           write_people1("libraryRead.txt");
                           for(it=l1.begin();it!=l1.end();++it){
                            r1.setId(it->getId());
                            r1.setnameR(it->getnameR());
                            r1.sethome(it->gethome());
                            r1.setnum(it->getnum());
                            r1.setloed(it->getloed());
                            write_people(r1,"libraryRead.txt");
                           }
                           write_people1("Book.txt");
                            for(it1=v1.begin();it1!=v1.end();++it1){
                                    b1.setm(it1->getmanger());
                                    b1.setnum(it1->getnum());
                                    b1.setnameb(it1->getnameb());
                                    b1.setname(it1->getname());
                                    b1.setp(it1->getp());
                                    b1.setsum(it1->getsum());
                                    b1.setloan(it1->getloan());
                                    b1.seta(it1->geta());
                                    b1.setb(it1->getb());
                                    b1.setc(it1->getc());
                                    write_people(b1,"Book.txt");
                            }
                            cout<<"借书成功!"<<endl;
        }

        break;
    case 2:
        q=0,q1=0,q2=0;
        w=Read_Book(v2,"library.txt");
        Read_people(l1,"libraryRead.txt");
        w=Read_Book(v1,"Book.txt");
        cout<<"输入还书读者的读者号:"<<endl;
        cin>>a;
        cout<<"输入还书的书号:"<<endl;
        cin>>m;
        for(it2=v2.begin();it2!=v2.end();++it2){
            if(strcmp(it2->getname(),a)==0){
                q=1;
                if(it2->getbook()==m){
                    q1=1;
                    if(strcmp(it2->getloedtime(),"无")!=0){
                        q2=1;
                        cout<<"该书已还!"<<endl;
                            break;
                    }
                    for(it=l1.begin();it!=l1.end();++it){
                        if(strcmp(it->getId(),a)==0){
                            it->setloed(it->getloed()-it2->getsum());
                        }
                    }
                    for(it1=v1.begin();it1!=v1.end();++it1){
                        if(it1->getnum()==m){
                            it1->setloan(it1->getloan()-it2->getsum());
                            it1->setsum(it1->getsum()+it2->getsum());
                        }
                    }
                    cout<<"输入还书时间:"<<endl;
                    cin>>b;
                    it2->setloedtime(b);
                }
            }

        }
        if(q==0) cout<<"没有该读者信息!"<<endl;
        if(q==1&&q1==0&&q2==0) cout<<"该读者没有借取该书!"<<endl;
        if(q==1&&q1==1&&q2==0) {
                           write_people1("libraryRead.txt");
                           for(it=l1.begin();it!=l1.end();++it){
                            r1.setId(it->getId());
                            r1.setnameR(it->getnameR());
                            r1.sethome(it->gethome());
                            r1.setnum(it->getnum());
                            r1.setloed(it->getloed());
                            write_people(r1,"libraryRead.txt");
                           }
                           write_people1("Book.txt");
                            for(it1=v1.begin();it1!=v1.end();++it1){
                                    b1.setm(it1->getmanger());
                                    b1.setnum(it1->getnum());
                                    b1.setnameb(it1->getnameb());
                                    b1.setname(it1->getname());
                                    b1.setp(it1->getp());
                                    b1.setsum(it1->getsum());
                                    b1.setloan(it1->getloan());
                                    b1.seta(it1->geta());
                                    b1.setb(it1->getb());
                                    b1.setc(it1->getc());
                                    write_people(b1,"Book.txt");
                            }
                            write_people1("library.txt");
                            for(it2=v2.begin();it2!=v2.end();++it2){
                                l.setname(it2->getname());
                                l.setbook(it2->getbook());
                                l.setsum(it2->getsum());
                                l.setloantime(it2->getloantime());
                                l.setloedtime(it2->getloedtime());
                                write_people(l,"library.txt");
                            }
            cout<<"还书成功!"<<endl;
        }

        break;
    case 3:
        t=0;
        break;
    default: break;
    }
    }
}

void menu(int m,char *ch,list<People> l){
    if(m==1){
        int t=1,n;
        while(t){
                cout<<"***************************************"<<endl;
                cout<<"1.用户管理"<<endl;
                cout<<"2.图书管理"<<endl;
                cout<<"3.退出"<<endl;
                cout<<"***************************************"<<endl;
                cin>>n;
                switch(n){
                case 1:
                    user_system(m,ch,l);
                    break;
                case 2:
                    book_system(m);
                    break;
                case 3:
                    t=0;
                    break;
                default: break;
                }
    }}
    if(m==2){
        int t1=1,n1;
        while(t1){
                cout<<"***************************************"<<endl;
                cout<<"1.图书管理"<<endl;
                cout<<"2.图书流通管理"<<endl;
                cout<<"3.退出"<<endl;
                cout<<"***************************************"<<endl;
                cin>>n1;
                switch(n1){
                case 1:
                    book_system(m);
                    break;
                case 2:
                    book2_stream();
                    break;
                case 3:
                    t1=0;
                    break;
                default: break;
                }
    }
    }
    if(m==3){
    int t2=1,n2;
    while(t2){
                cout<<"***************************************"<<endl;
                cout<<"1.用户管理"<<endl;
                cout<<"2.读者管理"<<endl;
                cout<<"3.退出"<<endl;
                cout<<"***************************************"<<endl;
                cin>>n2;
                switch(n2){
                case 1:
                    user_system(m,ch,l);
                    break;
                case 2:
                    read_system();
                    break;
                case 3:
                    t2=0;
                    break;
                default: break;
                }
}}
}
int main()
{
    list <People> l1;
    People p1;
    int t1=1,t,m;
    char name[20],code[16];
    while(t1){
        cout<<"*******************图书管理系统*********************"<<endl;
        cout<<"1.登入"<<endl;
        cout<<"2.注册"<<endl;
        cout<<"3.退出"<<endl;
        cout<<"****************************************************"<<endl;
        cin>>m;
        switch(m){
        case 1:
            t=0;
            for(int i=0;i<3;i++){
                    Read_people(l1,"library_people12345.txt");
                    cout<<"输入账号:";
                    cin>>name;
                    cout<<"输入密码:";
                    int m=16,j=0;
                    char c;
                    memset(code,0,sizeof(code));
                    getchar();
                    while(m--){
                    if((c=getch())=='\n'){
                        break;
                    }
                    code[j++]=c;
                   cout<<'*';
                   }cout<<endl;
                    list<People>::iterator it;
                for(it=l1.begin();it!=l1.end();++it){
                   if(strcmp(it->getname(),name)==0&&strcmp(it->getcode(),code)==0){
                    cout<<"登入成功!"<<endl;
                    t=1;
                    menu(it->getid(),it->getname(),l1);
                    break;
                    }}
                  if(t) break;
                  if(i!=2) cout<<"密码错误 请在次输入!"<<endl;
                  else if(i==2) cout<<"三次输入错误,可尝试重新注册!"<<endl;
            }
            break;
        case 2:
            p1.seta();
            cout<<"注册成功!"<<endl;
            write_people(p1,"library_people12345.txt");
            break;
        case 3:
            t1=0;
            break;
         default: break;



    }
    }
    return 0;
}

实现类

用户-People类

(People.h文件)

#ifndef PEOPLE_H
#define PEOPLE_H


class People
{
   private:
    char name[20];
    char code[16];
    int identity;
    public:
        friend int getch( );
    People(char *name1="0",char *code1="0",int identity1=0){
        strcpy(name,name1);
        strcpy(code,code1);
        identity=identity1;
    };
    People(const People &p);
    void setname(char *m){
        strcpy(name,m);
    };
    void setcode(char *p){
        strcpy(code,p);
    };
    void setid(int i){
        identity=i;
    };
    void seta();
    void change();
    char *getname();
    char *getcode();
    int getid(){return identity;};
};

#endif // PEOPLE_H

(People.cpp文件)

#include <bits/stdc++.h>
#include <termios.h>
#include <unistd.h>
#include<string.h>
#include "People.h"
using namespace std;
People::People(const People &p){
      strcpy(name,p.name);
      strcpy(code,p.code);
      identity=p.identity;
}
char* People::getname(){
    return name;
}
char* People::getcode(){
    return code;
}

void People::seta(){
    cout<<"输入账号:";
    cin>>name;
    cout<<"输入密码:";
    cin>>code;
    cout<<"选择你的身份"<<endl;
    cout<<"1.普通读者"<<endl;
    cout<<"2.图书管理员"<<endl;
    cout<<"3.系统管理员"<<endl;
    int n;
    cin>>n;
    switch(n){
        case 1:identity=1;
        break;
        case 2: identity=2;
        break;
        case 3: identity=3;
        break;
    }
}

读者信息-Read_stream类

(Read_stream.h文件)

#ifndef READ_STREAM_H
#define READ_STREAM_H


class Read_stream
{
    public:
        Read_stream();
        char* getId();
        char* getnameR();
        char* gethome();
        char* getnum();
        int getlo();
        int getloed();
        void setlo(int a);
        void setloed(int a);
        void setId(char *c);
        void setnameR(char *c);
        void sethome(char *c);
        void setnum(char *c);
        Read_stream operator =(int);
    private:
        char Id[20];
        char nameR[20];
        char home[30];
        char num[20];
        int lo;
        int loed;
};

#endif // READ_STREAM_H

(Read_stream.cpp文件)

#include<cstring>
#include "Read_stream.h"

Read_stream::Read_stream()
{
   strcpy(Id,"0");
   strcpy(nameR,"0");
   strcpy(home,"0");
   strcpy(num,"0");
   lo=0;
   loed=0;
}
char*Read_stream::getId(){
    return Id;
}
char*Read_stream::getnameR(){
    return nameR;
}
char*Read_stream::gethome(){
    return home;
}
char*Read_stream::getnum(){
    return  num;
}
void Read_stream::setId(char *c){
    strcpy(Id,c);
}
void Read_stream::setnameR(char *c){
    strcpy(nameR,c);
}
void Read_stream::sethome(char *c){
    strcpy(home,c);
}
int Read_stream::getlo(){
    return lo;
}
int Read_stream::getloed(){
    return loed;
}
void Read_stream::setlo(int a){
    lo=a;
}
void Read_stream::setloed(int a){
    loed=a;
}
void Read_stream::setnum(char *c){
    strcpy(num,c);
}
Read_stream Read_stream::operator=(int){
    Read_stream r1;
    r1.setId(Id);
    r1.setnameR(nameR);
    r1.sethome(home);
    r1.setnum(num);
    r1.setlo(lo);
    r1.setloed(loed);
    return r1;
}

图书总信息-Book类

(Book.h文件)

#ifndef BOOK_H
#define BOOK_H


class Book
{
    public:
        Book();
        int getmanger(){
            return manger;
        };
        char* getnameb(){
            return nameb;
        };
        char* getname(){
            return name;
        };
        char* getp(){
            return publish;
        };
        int getnum(){
            return num;
        };
        int getloan(){
            return loan;
        };
        int geta(){
            return a;
        };
        int getb(){
            return b;
        };
        int getc(){
            return c;
        };
        int getsum(){
            return sum;
        };
        void setm(int n){
            manger=n;
        };
        void setnameb(char *c){
            strcpy(nameb,c);
        };
        void setname(char* c){
            strcpy(name,c);
        };
        void setp(char* c){
            strcpy(publish,c);
        };
        void setnum(int n){
            num=n;
        };
        void setsum(int n){
            sum=n;
        };
        void setloan(int n){
            loan=n;
        };
        void seta(int n){
            a=n;
        };
        void setb(int n){
            b=n;
        };
        void setc(int n){
            c=n;
        };
    private:
        int manger;
        int num;
        char nameb[30];
        char name[20];
        char publish[50];
        int sum;
        int loan;
        int a;
        int b;
        int c;
};

#endif // BOOK_H

(Book.cpp文件)

#include<cstring>
#include "Book.h"

Book::Book()
{
   manger=0;
   strcpy(nameb,"0");
   strcpy(name,"0");
   strcpy(publish,"0");
   sum=0;
   loan=0;
   a=0;
   b=0;
   c=0;
}
  • Library类
    ( Library.h文件)
#ifndef LIBRARY_H
#define LIBRARY_H


class Library
{
    public:
        Library();
        char* getname(){
            return name;
        };
        int getbook(){
            return book;
        };
        int getsum(){
            return sum;
        };
        char *getloantime(){
            return loantime;
        };
        char* getloedtime(){
            return loedtime;
        };
        void setname(char* c){
            strcpy(name,c);
        };
        void setbook(int a){
            book=a;
        };
        void setsum(int a){
            sum=a;
        };
        void setloantime(char* c){
            strcpy(loantime,c);
        };
        void setloedtime(char* c){
            strcpy(loedtime,c);
        };

    private:
        char name[20];
        int book;
        int sum;
        char loantime[20];
        char loedtime[20];
};

#endif // LIBRARY_H

(Library.cpp文件)

#include<cstring>
#include "Library.h"
Library::Library()
{
    strcpy(name,"0");
    book=0;
    sum=0;
    strcpy(loantime,"0");
    strcpy(loedtime,"无");
}

作者索引-Name类

(Name.h文件)

#ifndef NAME_H
#define NAME_H


class Name
{
       public:
        Name();
        char* getname(){
            return name;
        };
        int getsum(){
            return sum;
        };
        int getn(){
            return n;
        };
        void setname(char* c){
            strcpy(name,c);
        };
        void setsum(int a){
            sum=a;
        };
        void setn(int a){
            n=a;
        };
    private:
        char name[30];
        int sum;
        int n;
};

#endif // NAME_H

(Name.cpp文件)

#include<cstring>
#include "Name.h"
Name::Name()
{
    strcpy(name,"0");
    sum=0;
    n=0;
}

书名索引-Bookname类

(Bookname.h文件)

#ifndef BOOKNAME_H
#define BOOKNAME_H
class Bookname
{
    public:
        Bookname();
        char* getname(){
            return name;
        };
        int getsum(){
            return sum;
        };
        int getn(){
            return n;
        };
        void setname(char* c){
            strcpy(name,c);
        };
        void setsum(int a){
            sum=a;
        };
        void setn(int a){
            n=a;
        };
    private:
        char name[30];
        int sum;
        int n;
};

#endif // BOOKNAME_H

(Bookname.cpp文件)

#include<cstring>
#include "Bookname.h"
Bookname::Bookname()
{
    strcpy(name,"0");
    sum=0;
    n=0;
}

出版社索引-Publishing类

(Publishing.h文件)

#ifndef PUBLISHING_H
#define PUBLISHING_H


class Publishing
{
   public:
        Publishing();
        char* getname(){
            return name;
        };
        int getsum(){
            return sum;
        };
        int getn(){
            return n;
        };
        void setname(char* c){
            strcpy(name,c);
        };
        void setsum(int a){
            sum=a;
        };
        void setn(int a){
            n=a;
        };
    private:
        char name[30];
        int sum;
        int n;
};

#endif // PUBLISHING_H

(Publishing.cpp文件)

#include<cstring>
#include "Publishing.h"

Publishing::Publishing()
{
    strcpy(name,"0");
    sum=0;
    n=0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值