freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c程序設(shè)計(jì)與應(yīng)用基礎(chǔ)第五章多態(tài)性習(xí)題答案(編輯修改稿)

2025-02-10 20:52 本頁面
 

【文章內(nèi)容簡介】 s1。 employee *emp[4]={amp。m1,amp。t1,amp。sm1,amp。s1}。 int i。 for(i=0。i4。i++) { emp[i]promote()。 emp[i]pay()。 emp[i]display()。 }}2)編寫一個(gè)程序,建立兩種類型的表:隊(duì)列與堆錢,使它們可以共用一個(gè)接口訪問。答案:include include include class List{public: List(){head=tail=next=NULL。} virtual void Store(int i)=0。 virtual int Retrieve()=0。 List *head, *tail, *next。 int num。}。class Quene:public List{public: void Store(int i)。 int Retrieve()。}。void Quene::Store(int i){ List *item。 item=new Quene。 if(!item) { coutAllocation error.endl。 abort()。 } itemnum=i。 if(tail) tailnext=item。 tail=item。 itemnext=NULL。 if(!head) head=tail。}int Quene::Retrieve(){ int i。 List *p。 if(!head) { coutQuene empty.endl。 return 0。 } i=headnum。 p=head。 head=headnext。 delete p。 return i。}class Stack :public List{public: void Store(int i)。 int Retrieve()。}。void Stack::Store(int i){ List *item。 item=new Stack。 if(!item) { coutAllocation error.endl。 abort()。 } itemnum=i。 if(head) itemnext=head。 head=item。 if(!tail) tail=head。}int Stack::Retrieve(){ int i。 List *p。 if(!head) { coutStack empty.endl。 return 0。 } i=headnum。 p=head。 head=headnext。 delete p。 return i。}void main(){ List *p。 Quene qobj。 p=amp。qobj。 for(int i=0。i3。i++) pStore(i+1)。 coutQuene.。 for(i=0。i3。i++) coutpRetrieve()。 Stack sobj。 p=amp。sobj。 for(i=0。i3。i++) pStore(i+1)。 coutendlStack:。 for(i=0。i3。i++) coutpRetrieve()。}3)編寫一個(gè)程序,先設(shè)計(jì)一個(gè)整數(shù)鏈表List類,然后從此鏈表派生出一個(gè)整數(shù)集合類set,在集合舉中增加一個(gè)元素個(gè)數(shù)的數(shù)據(jù)項(xiàng)。集合類的插入操作與鏈表相似(只是不插入重復(fù)元素),并且插入后,表示元素個(gè)數(shù)的數(shù)據(jù)成員需增值。集合類的刪除操作是在鏈表刪除操作的基礎(chǔ)上對(duì)元素個(gè)數(shù)做減1操作:而查找和顯示操作是相同的。答案:include enum boolean {False,True}。struct Node{ int val。 Node *next。}。class List{public:
點(diǎn)擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1