C++图书馆管理系统 详细代码
用容器做的,這個(gè)是我的弱項(xiàng),但大體功能都實(shí)現(xiàn)。
圖書(shū)館信息系統(tǒng),是一個(gè)單用戶系統(tǒng),所以不用考慮有多少種角色。
實(shí)現(xiàn)要點(diǎn):
1、對(duì) 圖書(shū):
顯示圖書(shū)館里的全部書(shū)籍
按書(shū)名查詢(xún)
按作者查詢(xún)
按分類(lèi)查詢(xún)
對(duì)圖書(shū)的增刪改
從文件讀入全部圖書(shū)
把容器里的全部圖書(shū)寫(xiě)回文件中
2、對(duì) 讀者:(與圖書(shū)類(lèi)似)
對(duì) 借書(shū)、還書(shū):
借書(shū):唯一編號(hào),讀者id,書(shū)籍id,借書(shū)時(shí)間,標(biāo)志
還書(shū):唯一編號(hào),讀者id,書(shū)籍id,還書(shū)時(shí)間,標(biāo)志
查詢(xún)某用戶的全部借書(shū)還書(shū)記錄
查詢(xún)某用戶 在某時(shí)間段 的全部借書(shū)還書(shū)記錄
查詢(xún)某用戶全部未還書(shū)籍
查詢(xún)某本書(shū)被哪些人借閱過(guò)
框架樣例:
class Book {
private:
unsigned int id; /// 書(shū)籍編號(hào)
string name; /// 書(shū)名
… 等等屬性,請(qǐng)自行補(bǔ)充完善
public:
Book() {
… 請(qǐng)自行補(bǔ)充完善
}
}
增、刪(標(biāo)記刪除、不實(shí)際刪除)、改, operator << operator >> 查詢(xún):按書(shū)名、按作者、按分類(lèi)、...等等等等成員函數(shù)
}
class Reader {
private:
unsigned int id; /// 讀者編號(hào)
string name; /// 姓名
… 等等屬性,請(qǐng)自行補(bǔ)充完善
public:
Reader() {
… 請(qǐng)自行補(bǔ)充完善
}
}
增、刪(標(biāo)記刪除、不實(shí)際刪除)、改 operator << operator >> 查詢(xún):按姓名、按電話號(hào)碼、按身份、...等等等等成員函數(shù)}
/// 借書(shū)、還書(shū)
class borrowReturn {
private:
unsigned int id; /// 唯一編號(hào)、主鍵
unsigned int readerId; /// 讀者編號(hào)
unsigned int BookId; /// 書(shū)籍編號(hào)
日期時(shí)間類(lèi)型 datetime; /// 借書(shū) 或 還書(shū) 的時(shí)間
public:
borrowReturn () {
… 請(qǐng)自行補(bǔ)充完善
}
}
分別定義容器,存放:
全部書(shū)籍
全部讀者
全部借還書(shū)記錄
int main() {
在進(jìn)入程序后,首先:
1. 讀入 書(shū)籍文件 里的全部記錄,存入 書(shū)籍容器
2. 讀入 讀者文件 里的全部記錄,存入 讀者容器
3. 讀入 全部借還書(shū)文件 里的全部記錄,存入 借還書(shū)容器
}
/***項(xiàng)目名稱(chēng):圖書(shū)管理系統(tǒng)*語(yǔ)言:C++**/#include <iostream> #include <fstream> #include <string> #include <iomanip> #include <vector> #include <stdlib.h> #include <string.h> using namespace std;//構(gòu)建圖書(shū)類(lèi)類(lèi) class Book { public:int b_sum=0; //圖書(shū)數(shù)string key; //管理員密碼vector<Book> b_array; //記錄圖書(shū)類(lèi)void B_clear(); //清理已有圖書(shū)信息void B_Read_file(); //讀取圖書(shū)文件void B_Save_file(); //保存圖書(shū)文件bool Book_add(); //添加圖書(shū)信息bool Book_mod(); //修改圖書(shū)信息bool Book_del(); //刪除圖書(shū)信息bool Personnel_System(); //登錄char b_num[15]; //編號(hào)char b_name[30]; //書(shū)名char author[20]; //作者char ISBN[30]; //ISBNint b_quantity; //圖書(shū)數(shù)量bool B_SetInto(); //設(shè)置圖書(shū)信息friend istream& operator>>(istream& in, Book& cp); //提取運(yùn)算符重載friend ostream& operator<<(ostream& out, Book& cp); //插入運(yùn)算符重載bool B_If_match(char p[30]);void b_display(); //圖書(shū)信息顯示bool Book_search();void Deletenum();};//設(shè)置圖書(shū)信息 bool Book::B_SetInto() {char temp[15];cout << "請(qǐng)輸入圖書(shū)號(hào):(輸入+退出)";cin >> temp;if (temp[0] == '+')return false;strcpy(b_num, temp);cout << "書(shū)名:";cin >> b_name;cout << "作者:";cin >> author;cout << "ISBN";cin >> ISBN;cout << "數(shù)量:";cin >> b_quantity;return true; }//提取運(yùn)算符重載 istream& operator>>(istream& in, Book& cp) {in >> cp.b_num >> cp.b_name >> cp.author >> cp.ISBN >> cp.b_quantity;return in; }//插入運(yùn)算符重載 ostream& operator<<(ostream& out, Book& cp) {out << cp.b_num <<' '<< cp.b_name <<' '<< cp.author <<' '<< cp.ISBN <<' '<< cp.b_quantity<<'\n';return out; }//判斷圖書(shū)號(hào)是否匹配 bool Book::B_If_match(char p[30]) {return (!strcmp(b_num, p)|| !strcmp(b_name, p)); }//顯示函數(shù) void Book:: b_display() {cout << setiosflags(ios::left) << setw(12) << b_num << " " << setw(30) << b_name << " " << setw(10) << author << endl<< setw(20) << ISBN << " " <<"剩余數(shù)量:"<< setw(3) << b_quantity << endl; }//清理已有圖書(shū)信息 void Book::B_clear() {b_array.clear();b_sum = 0; }//讀取圖書(shū)文件 void Book::B_Read_file() {ifstream b_file;b_file.open("Book_Information.txt");if (!b_file.is_open()){cerr << "文件\"Book_Information.txt\"無(wú)法打開(kāi)\n";exit(1);}while (!b_file.eof()){Book _book;b_file >> _book;b_array.push_back(_book);b_sum++;};b_sum--;b_file.close(); }//保存圖書(shū)文件 void Book::B_Save_file() {ofstream b_file("Book_Information.txt");if (!b_file){cerr << "文件\"Book_Information.txt\"無(wú)法打開(kāi)!\n";exit(1);}int i = -1;while (++i < b_sum){b_file << b_array[i];}b_file.close(); }//添加圖書(shū)信息 bool Book::Book_add() {B_Read_file();Book _book;cout << "請(qǐng)進(jìn)行信息錄入。按“+”結(jié)束!\n";do{b_array.push_back(_book);} while (b_array[b_sum++].B_SetInto());b_sum--;b_array.pop_back();return true; }//修改圖書(shū)信息 bool Book::Book_mod() {char _b_num[30];B_Read_file();cout << "請(qǐng)輸入您要修改的圖書(shū)信息的圖書(shū)號(hào)或書(shū)名:";cin >> _b_num;for (int i = 0; i < b_sum; i++){if (b_array[i].B_If_match(_b_num)){cout << "該圖書(shū)的原信息為:\n";b_array[i].b_display();cout << "請(qǐng)輸入正確信息! \n";b_array[i].B_SetInto();b_sum++; //保持總航線數(shù)不變return true;}if (i == b_sum){cout << "抱歉!您要修改的信息不存在! " << endl;return false;}break;}B_Save_file(); }void Book::Deletenum(){int n;cout<<"請(qǐng)輸入刪除的數(shù)量:";cin>>n;b_quantity -=n;}//刪除圖書(shū)信息 bool Book::Book_del() {char _b_num[15];B_Read_file();cout << "請(qǐng)輸入您要?jiǎng)h除的圖書(shū)信息的圖書(shū)號(hào):";cin >> _b_num;for (int i = 0; i < b_sum; i++){if (b_array[i].B_If_match(_b_num)){cout << "該圖書(shū)的原信息為:\n";b_array[i].b_display();b_array[i].Deletenum(); b_sum--;return true;}if (i == b_sum){cout << "抱歉!您要?jiǎng)h除的信息不存在! " << endl;return false;}}B_Save_file(); }//查詢(xún)圖書(shū)信息 bool Book::Book_search() {char _b_num[30];B_Read_file();cout << "請(qǐng)輸入您要查詢(xún)的圖書(shū)信息的圖書(shū)號(hào)或書(shū)名:";cin >> _b_num;for (int i = 0; i < b_sum; i++){if (b_array[i].B_If_match(_b_num)){cout << "該圖書(shū)的信息為:\n";b_array[i].b_display();return true;}if (i == b_sum){cout << "抱歉!您要查詢(xún)的信息不存在! " << endl;return false;}break;}B_Save_file(); }//圖書(shū)管理系統(tǒng) bool Book::Personnel_System() {while (1){int menu_options;cout << "請(qǐng)輸入登錄密碼:";cin >> key;if (key == "123456") //登錄密碼while (1){cout << endl<< "***** 主菜單: **********" << endl<< "***** 工作人員 " << endl<< "***** 1——添加圖書(shū)信息 "<< "2——修改圖書(shū)信息" << endl<< "***** 3——?jiǎng)h除圖書(shū)信息 "<< "4——查詢(xún)圖書(shū)信息" << endl<< "***** 5——退出登錄"<<endl<< "你需要做什么?(1-5)" << endl;cin >> menu_options;switch (menu_options){case 1:Book_add(); break;case 2:Book_mod(); break;case 3:Book_del(); break;case 4:Book_search(); break;case 5:return false;default:cout << "輸入錯(cuò)誤,請(qǐng)重新選擇" << endl; break;}if (!(menu_options == 4)){cout << "是否確認(rèn)? 《確認(rèn)/(Y/y)》 《取消/(N/n)》" << endl;char yn;do{cin >> yn;} while (!(yn == 'Y' || yn == 'y' || yn == 'N' || yn == 'n'));if (yn == 'Y' || yn == 'y'){if (menu_options == 1|| menu_options == 2 || menu_options == 3){B_Save_file();}cout << "操作成功";}}B_clear();}else{cout << "密碼錯(cuò)誤!" << endl;continue;}}return true; }//界面初始化函數(shù) void login_init() {system("cls");cout << "\n>>>>>>>>>>歡迎進(jìn)入圖書(shū)管理系統(tǒng)<<<<<<<<<<" << endl<< "請(qǐng)輸入您的登錄方式" << endl<< "1——讀者管理 2——圖書(shū)管理 3——借閱管理 4--退出系統(tǒng)" << endl; }//構(gòu)建讀者類(lèi) class Student { public:int s_sum=0; //學(xué)生數(shù)string key; //管理員密碼vector<Student> s_array; //記錄學(xué)生類(lèi)void S_clear(); //清理已有學(xué)生信息void S_Read_file(); //讀取學(xué)生文件void S_Save_file(); //保存學(xué)生文件bool Student_add(); //添加學(xué)生信息bool Student_mod(); //修改學(xué)生信息bool Student_del(); //刪除學(xué)生信息bool Student_search();bool Student_System(); //學(xué)生登錄bool Personnel_System(); //工作人員登錄void login_init(); //登錄界面初始化Student(){memset(s_num, 0, sizeof(s_num));memset(s_name,0, sizeof(s_name));memset(tell, 0, sizeof(tell, 0, sizeof(tell)));borrow_max = 0;borrow_quantity = 0;memset(borrow_books, 0, sizeof(borrow_books));}char s_num[15]; //讀者編號(hào)char s_name[10]; //姓名char tell[30]; //電話號(hào)碼 int borrow_max; //最大借閱數(shù)量int borrow_quantity; //借閱數(shù)量char borrow_books[10][30]; //借閱圖書(shū)bool S_SetInto(); //設(shè)置學(xué)生信息friend istream& operator>>(istream& in, Student& cp); //提取運(yùn)算符重載friend ostream& operator<<(ostream& out, Student& cp); //插入運(yùn)算符重載bool S_If_match(char p[30]); //判斷學(xué)號(hào)是否匹配void s_display(); //顯示學(xué)生信息void Deletenum();};void Student::Deletenum(){borrow_quantity -=0;}//設(shè)置學(xué)生信息 bool Student::S_SetInto() {char temp[15];cout << "請(qǐng)輸入學(xué)號(hào):(輸入+退出)";cin >> temp;if (temp[0] == '+'){return false;}strcpy(s_num, temp);cout << "學(xué)生姓名:";cin >> s_name;cout << "電話號(hào)碼:";cin >> tell;do{cout << "最大借閱數(shù)量(1-10):";cin >> borrow_max;}while (borrow_max <= 0 || borrow_max > 10);return true; }//提取運(yùn)算符重載 istream& operator>>(istream& in, Student& cp) {in >> cp.s_num >> cp.s_name >> cp.tell >> cp.borrow_max >> cp.borrow_quantity;for (int i = 0; i < cp.borrow_quantity; i++){in >> cp.borrow_books[i];}return in; }//插入運(yùn)算符重載 ostream& operator<<(ostream& out, Student& cp) {out << cp.s_num << ' ' << cp.s_name << ' ' << cp.tell << ' ' << cp.borrow_max << ' ' << cp.borrow_quantity << ' ';for (int i = 0; i < 10; i++){out << cp.borrow_books[i] << ' ';if (i == 9){out << '\n';}}return out; }//判斷學(xué)號(hào)是否匹配 bool Student::S_If_match(char p[30]) {return (!strcmp(s_num, p)||!strcmp(s_name, p)); }//顯示學(xué)生信息 void Student::s_display() //顯示 {cout << setiosflags(ios::left) << "學(xué)號(hào):" << setw(12) << s_num << " " << setw(10) << s_name << " " << setw(25) << tell << endl<< "最大借閱量" << borrow_max << endl; }//清理已有學(xué)生信息 void Student::S_clear() {s_array.clear();s_sum = 0; }//讀取學(xué)生文件 void Student::S_Read_file() {ifstream s_file;s_file.open("Student_Information.txt");if (!s_file.is_open()){cerr << "文件\"Student_Information.txt\"無(wú)法打開(kāi)\n";exit(1);}while (!s_file.eof()){Student stu;s_file >> stu;s_array.push_back(stu);s_sum++;}s_sum--;s_file.close(); }//保存學(xué)生文件 void Student::S_Save_file() {ofstream s_file("Student_Information.txt");if (!s_file){cerr << "文件\"Student_Information.txt\"無(wú)法打開(kāi)!\n";exit(1);}int i = -1;while (++i < s_sum){s_file << s_array[i];}s_file.close(); }//添加學(xué)生信息 bool Student::Student_add() {S_Read_file();Student _stu;cout << "請(qǐng)進(jìn)行信息錄入。按“+”結(jié)束!\n";do{s_array.push_back(_stu);}while (s_array[s_sum++].S_SetInto());s_sum--;s_array.pop_back();return true; }//修改學(xué)生信息 bool Student::Student_mod() {char _s_num[15];S_Read_file();cout << "請(qǐng)輸入您要修改的學(xué)生信息的學(xué)號(hào)或名字:";cin >> _s_num;int i = 0;for (; i < s_sum; i++){if (s_array[i].S_If_match(_s_num)){cout << "該同學(xué)的原信息為:\n";s_array[i].s_display();cout << "請(qǐng)輸入正確信息! \n";s_array[i].S_SetInto();s_sum++; //保持學(xué)生數(shù)return true;}if (i == s_sum){cout << "抱歉!您要修改的信息不存在! " << endl;return false;}break;}S_Save_file(); }//刪除學(xué)生信息 bool Student::Student_del() {char _s_num[15];S_Read_file();cout << "請(qǐng)輸入您要?jiǎng)h除的學(xué)生信息的學(xué)號(hào):";cin >> _s_num;for (int i = 0; i < s_sum; i++){if (s_array[i].S_If_match(_s_num)){cout << "該同學(xué)的原信息為:\n";s_array[i].s_display();s_array[i].Deletenum(); s_sum--;return true;}if (i == s_sum){cout << "抱歉!您要?jiǎng)h除的信息不存在! " << endl;return false;}}S_Save_file(); }//查詢(xún)學(xué)生信息 bool Student::Student_search() {char _s_num[15];S_Read_file();cout << "請(qǐng)輸入您要查詢(xún)的學(xué)生信息的學(xué)號(hào)或名字:";cin >> _s_num;int i = 0;for (; i < s_sum; i++){if (s_array[i].S_If_match(_s_num)){cout << "該同學(xué)的原信息為:\n";s_array[i].s_display();return true;}if (i == s_sum){cout << "抱歉!您要修改的信息不存在! " << endl;return false;}break;}S_Save_file(); }//讀者管理系統(tǒng) bool Student::Personnel_System() {while (1){int menu_options;cout << "請(qǐng)輸入登錄密碼:";cin >> key;if (key == "123456") //登錄密碼while (1){cout << endl<< "***** 主菜單: **********" << endl<< "***** 工作人員 " << endl<< "***** 1——添加學(xué)生信息 "<< "2——修改學(xué)生信息" << endl<< "***** 3——?jiǎng)h除學(xué)生信息 "<< "4——查詢(xún)學(xué)生信息" << endl<< "***** 5——退出登錄"<<endl<< "你需要做什么?(1-9)" << endl;cin >> menu_options;switch (menu_options){case 1:Student_add(); break;case 2:Student_mod(); break;case 3:Student_del(); break;case 4:Student_search(); break;case 5:return false;default:cout << "輸入錯(cuò)誤,請(qǐng)重新選擇" << endl; break;}if (!(menu_options == 4)){cout << "是否確認(rèn)? 《確認(rèn)/(Y/y)》 《取消/(N/n)》" << endl;char yn;do{cin >> yn;} while (!(yn == 'Y' || yn == 'y' || yn == 'N' || yn == 'n'));if (yn == 'Y' || yn == 'y'){if (menu_options == 1 || menu_options == 2 || menu_options == 3){S_Save_file();}cout << "操作成功";}}S_clear();}else{cout << "密碼錯(cuò)誤!" << endl;continue;}}return true; }class management:public Student,public Book { public:string key; bool borrow_book(Student& cp);bool return_book(Student& cp);bool Student_System();bool s_login(Student& cp);char book[30];//書(shū)籍編號(hào) char stu[30];//學(xué)生編號(hào) char da[30];//日期 friend istream& operator>>(istream& in, management& cp);friend ostream& operator<<(ostream& out, management& cp);vector<management> c_array;//信息類(lèi) void c_Read_file();void c_Save_file();bool c_SetInto(); bool c_add();int c_sum=0;bool c_If_match(char p[30]);void c_display();int a;//標(biāo)記借出為0,還為1 bool c_search();};istream& operator>>(istream& in, management& cp) {in >> cp.book >> cp.stu >> cp.da >>cp.a;return in; }//插入運(yùn)算符重載 ostream& operator<<(ostream& out, management& cp) {out << cp.book <<' '<< cp.stu <<' '<< cp.da <<' '<<cp.a<<'\n';return out; }//讀取圖書(shū)文件 void management::c_Read_file() {ifstream c_file;c_file.open("S_Information.txt");if (!c_file.is_open()){cerr << "文件\"S_Information.txt\"無(wú)法打開(kāi)\n";exit(1);}while (!c_file.eof()){management _book;c_file >> _book;c_array.push_back(_book);c_sum++;};c_sum--;c_file.close(); }//保存圖書(shū)文件 void management::c_Save_file() {ofstream c_file("S_Information.txt");if (!c_file){cerr << "文件\"S_Information.txt\"無(wú)法打開(kāi)!\n";exit(1);}int i = -1;while (++i < c_sum){c_file << c_array[i];}c_file.close(); }//學(xué)生憑學(xué)號(hào)登錄 bool management::s_login(Student& cp) {char _s_num[15];S_Read_file();cout << "請(qǐng)輸入您的學(xué)號(hào):";cin >> _s_num;for (int i = 0; i < s_sum; i++){if (s_array[i].S_If_match(_s_num)){cp=s_array[i];cout << "歡迎您," << cp.s_name << "同學(xué)!" << endl;S_clear();return true;}}S_clear();return false; }//設(shè)置圖書(shū)信息 bool management::c_SetInto() {char temp[15];cout << "請(qǐng)輸入書(shū)籍編號(hào):(輸入+退出)";cin >> temp;if (temp[0] == '+')return false;strcpy(book, temp);cout << "讀者編號(hào):";cin >> stu;cout << "日期:";cin >> da;cout<<"0借1還";cin>>a;return true; }bool management::c_add() {c_Read_file();management _book;cout << "請(qǐng)進(jìn)行信息錄入。按“+”結(jié)束!\n";do{c_array.push_back(_book);} while (c_array[c_sum++].c_SetInto());c_sum--;c_array.pop_back();return true; }//判斷圖書(shū)號(hào)是否匹配 bool management::c_If_match(char p[30]) {return (!strcmp(book, p)); }//顯示函數(shù) void management:: c_display() {cout << setiosflags(ios::left) << setw(12) << book<< " " << setw(30) << stu << " " << setw(10) << da << endl<< setw(20) << a<< endl;}//查詢(xún)jieyue信息 bool management::c_search() {char _s_num[15];c_Read_file();cout << "請(qǐng)輸入您要查的書(shū)籍編號(hào):";cin >> _s_num;int i = 0;for (; i < c_sum; i++){if (c_array[i].c_If_match(_s_num)){cout << "借閱記錄:\n";c_array[i].c_display();return true;}if (i == c_sum){cout << "抱歉!您要修改的信息不存在! " << endl;return false;}break;}c_Save_file(); }//借書(shū) bool management::borrow_book(Student& cp) {S_Read_file();B_Read_file();c_Read_file();char _b_num[30];cout << "請(qǐng)輸入想借圖書(shū)的圖書(shū)號(hào)或書(shū)名:";cin >> _b_num;for (int i = 0; i < b_sum; i++){if (b_array[i].B_If_match(_b_num)){cout << "該圖書(shū)的信息為:\n";b_array[i].b_display();b_array[i].b_quantity--;c_add();c_Save_file(); if (cp.borrow_quantity > cp.borrow_max - 1){cout << "抱歉,您已達(dá)借書(shū)最大上限!" << endl;return false;}strcpy(cp.borrow_books[cp.borrow_quantity++],b_array[i].b_name);for (int j = 0; j < s_sum; j++){if (s_array[j].S_If_match(cp.s_num)){s_array[j]=cp;return true;}}}if (i == b_sum - 1){cout << "抱歉!您想借的圖書(shū)未收錄! " << endl;return false;}}}//還書(shū) bool management::return_book(Student& cp) {S_Read_file();B_Read_file();char _b_num[30];cout << "請(qǐng)輸入想還圖書(shū)的圖書(shū)號(hào)或書(shū)名:";cin >> _b_num;for (int i = 0; i < b_sum; i++){if (b_array[i].B_If_match(_b_num)){cout << "該圖書(shū)的信息為:\n";b_array[i].b_display();b_array[i].b_quantity++;c_add();c_Save_file(); for (int k = 0; k < cp.borrow_quantity; k++){if (!strcmp(cp.borrow_books[k],b_array[i].b_name)){for (int m = k; m < cp.borrow_quantity-1; m++){strcpy(cp.borrow_books[m], cp.borrow_books[m+1]);}strcpy(cp.borrow_books[--cp.borrow_quantity], ""); // cp.borrow_quantity--;break;}}for (int j = 0; j < s_sum; j++){if (s_array[j].S_If_match(cp.s_num)){s_array[j] = cp;return true;}}}if (i == b_sum){cout << "抱歉!您想還的圖書(shū)未收錄! " << endl;return false;}} }//學(xué)生登錄 bool management::Student_System() {while (1){ Student cp;bool key = s_login(cp);while (key){int menu_options;cout << "***** 主菜單: **********" << endl<< "***** 學(xué)生: " << endl<< "***** 1——借閱圖書(shū)" << endl<< "***** 2——?dú)w還圖書(shū)" << endl<< "***** 3——按學(xué)號(hào)查詢(xún)書(shū)籍信息" << endl<< "***** 4——退出登錄" << endl<< "你需要做什么?(選擇1-4)" << endl;cin >> menu_options;switch (menu_options){case 1:borrow_book(cp); break;case 2:return_book(cp); break;case 3:c_search();break;case 4:return false;}if (menu_options == 1 || menu_options == 2){cout << "是否確認(rèn)? 《確認(rèn)/(Y/y)》 《取消/(N/n)》" << endl;char yn;do{cin >> yn;} while (!(yn == 'Y' || yn == 'y' || yn == 'N' || yn == 'n'));if (yn == 'Y' || yn == 'y'){cout << "操作成功!" << endl;S_Save_file();B_Save_file();}}S_clear();B_clear();}cout << "未找到您的信息!" << endl;}return true; }//主函數(shù) int main() {Book xiangnan;Student duzhe; management mag;//若文件不存在,則新建文件//存放學(xué)生信息ofstream Student_Information("Student_Information.txt", ios::app);if (!Student_Information){cerr << "文件\"flight information.dat\"無(wú)法打開(kāi)!\n";exit(1);}Student_Information.close();//存放圖書(shū)信息ofstream Book_Information("Book_Information.txt", ios::app);if (!Book_Information){cerr << "文件\"flight information.dat\"無(wú)法打開(kāi)!\n";exit(1);}Book_Information.close();ofstream S_Information("S_Information.txt", ios::app);if (!S_Information){cerr << "文件\"flight information.dat\"無(wú)法打開(kāi)!\n";exit(1);}S_Information.close();int dlry; //登陸人員while (1){login_init(); //界面初始化cin >> dlry;if (dlry == 1){duzhe.Personnel_System();}else if (dlry == 2){xiangnan.Personnel_System();}else if (dlry == 3){mag.Student_System();}else if (dlry == 4){return 0;}else{cout << "輸入錯(cuò)誤,請(qǐng)重新選擇!" << endl;}}return 0; }總結(jié)
以上是生活随笔為你收集整理的C++图书馆管理系统 详细代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 微商软文标题怎么写才吸引人?
- 下一篇: 计算机电源输出电压 电流,开关电源的输出