#include<iostream>
#include<string>
using namespace std;
class Book
{
protected:
char bookname[100];
int number;
char authorInformation[100];
public:
Book(char *booknam,int num,char *authorInfor)
{
strcpy(bookname, booknam);
number = num;
strcpy(authorInformation, authorInfor);
cout << "书名:" << bookname<<endl;
cout << "编号:" << number << endl;
cout << "作者属性:" << authorInformation << endl;
}
};
class Reader :public Book
{
private:
char name[20];
int ID;
char lendingInformation[100];
public:
Reader(char *booknam, int num, char *authorInfor, char *nam, int id, char *lendingInfor) :Book(bookname, num, authorInfor)
{
strcpy(name, nam);
ID = id;
strcpy(lendingInformation, lendingInfor);
cout << "读者姓名:" << name<<endl;
cout << "ID:" << id << endl;
cout << "借书属性:" << lendingInformation << endl;
}
};
int main()
{
Reader r("annnn", 1005, "Jane Austen(1775-1817),English novelist", "Ann", 001, "于一月后归还");
system("pause");
return 0;
}
这都不会
相关分类