d while } 7. bdatabase.h (图书信息库类) #ifndef _bdatabase_h_ #define _bdatabase_h_ #include "book.h" #include <iostream> using namespace std; const int Maxb = 100; 学生姓名学号专业计算机类年级、班级课程名称程序设计实验实验项目小小图书馆实验时间年月日实验指导老师实验评分 9 class BDatabase { private : int top; Book book[Maxb]; public : BDatabase(); void clear(); int addbook( int n, char *na); Book *query( int bookid); void list(); void bookdata(); ~BDatabase(); }; #endif 8. bdatabase.cpp (图书信息库类的实现) #include "stdafx.h" #include <fstream> #include <iostream> #include "bdatabase.h" using namespace std; BDatabase ::BDatabase() { Book s; top = -1; fstream file; file.open( "book.dat" , ios ::in | ios ::binary); while (1) { file.read(( char *)&s, sizeof (s)); if (! file) break ; top++; book[top] = s; } file.close(); } void BDatabase ::clear() { top = -1;