class Book
{
string title;
int category;
public:
Book(const string& abook, int num);
string getTitle() const;
int getCategory() const;
friend ostream& operator<<(ostream& os, const Book& abook);
friend istream& operator>>(istream& is, Book& abook);
};
class Reader // base class
{
private:
string reader_name;
vector<Book> bookLists;
public:
string showname() const;
void add(const Book& abook); // organize book list
friend ostream& operator<<(ostream& os, const Reader& read_name);
friend istream& operator>>(istream& is, Reader& read_name);
};
class fantasyReader : public Reader { };
class horrorReader : public Reader { };
class scienceReader : public Reader { } ;
class mysteryReader : public Reader { };
我有两个给定的文本文件。
1) Reader.txt
For ex.
大卫 0
2) Book.txt
For ex
Riddick 0
在main函数中,指向Reader的obj的指针数组指向每个派生类;
ex
Reader *obj[10];
int pos =0;
obj[pos++] = new fantasyReader();
主要目标是组织书籍列表并放入适当的类别和适当的读者
并将它们写入一个新的文本文件中。
ex.
-David-
Riddick
-John-
乌鸦
我的问题
我不确定运算符 > 内部应该包含什么
适用于班级书籍和班级读者
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)