//card.h #include //string, getline #include //ostream, istream, cin, cout, endl using namespace std; #ifndef CARD_H #define CARD_H class card{ public: virtual ~card(); //virtual destructor makes sure that the //base part and derived part are destroyed. void setTitle(string t); string getTitle(); void setKeyword(string k); string getKeyword(); //for output, can't use operator<< because it is NOT a //member function, so it cannot be declare VIRTUAL //similarly for operator>> virtual ostream & display(ostream & out); //prints //Title: title //Keyword: keyword virtual istream & read(istream & in); //reads //title //keyword protected: string title; string keyword; }; class book_card:public card{ public: ostream & display(ostream & out); //prints // BOOK //Title: title //Author: author //Keyword: keyword number of pages: pages //newline istream & read(istream & in); //reads //title //keyword //author //pages protected: string author; int pages; }; class journal_card:public card{ public: ostream & display(ostream & out); //prints // JOURNAL //Title: title //Keyword: keyword //publisher: publisher //From volume start_volume number start_number //newline istream & read(istream & in); //reads //title //keyword //start_volume start_number //publisher protected: int start_volume; int start_number; string publisher; }; #endif