描述
此题以及后面几题要求你设计并实现一个Book类,你可以想象这是图书馆系统的一部分。
Book类应该包含ISBN号、书名、作者和版权日期的成员,以及表示是否已经借出的成员。
创建能够返回这些成员的值的函数,以及借书和还书的函数。
将ISBN号存储为string
输入
输入有多行,每一行分别是书名,作者名,ISBN号和出版时间
输出
将所有书籍按照ISBN排序后输出
样例输入
活着 余华 9787506365437 2012-8-1 围城 钱钟书 9787020024759 1991-2 边城 沈从文 9787537823425 2002-4
样例输出
围城 钱钟书 9787020024759 1991-2 活着 余华 9787506365437 2012-8-1 边城 沈从文 9787537823425 2002-4
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
class book
{
private:
string name;
string author;
string isbn;
string data;
public:
string get_name()
{
return name;
}
string get_author()
{
return author;
}
string get_isbn()
{
return isbn;
}
string get_data()
{
return data;
}
bool operator<(const book& b)
{
return isbn<;
}
bool set(string name,string author,string isbn,string data)
{
this->name=name;
this->author=author;
this->isbn=isbn;
this->data=data;
}
void print()
{
cout<<name<<" "<<author<<" "<<isbn<<" "<<data<<endl;
}
}books[100+5] ;
int main()
{
string a,b,c,d;
int n=0;
while(cin>>a>>b>>c>>d)
{
books[n++].set(a,b,c,d);
}
sort(books,books+n);
for(int i=0;i<n;i++)
{
books[i].print();
}
return 0;
}