C++实现图书馆借书管理系统:列出读者借书情况
#include
using namespace std;
// 书籍类 class Book { public: Book(string title, int id, string author, string publisher) { this->title = title; this->id = id; this->author = author; this->publisher = publisher; } string getTitle() { return title; } int getId() { return id; } string getAuthor() { return author; } string getPublisher() { return publisher; } private: string title; int id; string author; string publisher; };
// 读者类
class Reader {
public:
Reader(string name, int id) {
this->name = name;
this->id = id;
}
string getName() {
return name;
}
int getId() {
return id;
}
vector
int main() { // 创建书籍和读者对象 Book book1('C++程序设计', 1001, '谭浩强', '清华大学出版社'); Book book2('Java程序设计', 1002, '李刚', '人民邮电出版社'); Book book3('Python程序设计', 1003, 'Guido van Rossum', '机械工业出版社'); Reader reader('张三', 2001);
// 借书
reader.borrowBook(book1);
reader.borrowBook(book2);
reader.borrowBook(book3);
// 输出借书情况
reader.printBorrowedBooks();
return 0;
原文地址: https://www.cveoy.top/t/topic/oakZ 著作权归作者所有。请勿转载和采集!