?#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;}
1 回答
已采納

這都不會
TA貢獻72條經驗 獲得超92個贊
小伙子,因為你
public: Reader(char?*booknam,?int?num,?char?*authorInfor,
這一行打錯了
應該是
Reader(char?*bookname
你少打了一個e
點擊展開后面4條
- 1 回答
- 0 關注
- 1378 瀏覽
添加回答
舉報
0/150
提交
取消