




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
C++語(yǔ)言程序設(shè)計(jì)開卷筆 考試時(shí)間:120分 學(xué)號(hào) 班號(hào) —二二三 在類中必須成員函數(shù)的 原型 類型或 進(jìn)行函數(shù)重載時(shí),被重載的同名函數(shù)如果都沒有用const修飾,則 通過一個(gè)常對(duì)象只能調(diào)用它的常成員函數(shù),不能調(diào)用其他成 #include<iostream.h>#include<string.h>classBase{charmsg[30];
intn;Base(chars[],int }void }classDerived1:public{intn;Derived1(int n=m;void }classDerived2:public{
intn;Derived2(int{n=m;void }void{BaseB("BaseClass",1);Derived2D;}11BaseClass10#include<iostream.h>classSampvoidSetij(inta,int }
intGetMuti(){returni*j;}inti;intintfor(int{Sampfor(intp=newcout<<"Muti["<<k<<"] returnreturn}}Muti[0]is:0Muti[1]is:1Muti[2]is:4Muti[3]is:9Muti[4]Muti[0]is:0Muti[1]is:1Muti[2]is:4Muti[3]is:9Muti[4]is:16#include<iostream.h>#include<stdlib.h>classVector{Vector(ints=100);int&Elem(intndx);voidDisy(void);voidSet(void);
intsize;int*buffer;Vector::Vector(int{buffer=new}int&Vector::Elem(int{{cout<<"errorinindex"<<endl;}return}
for(intj=0;j<size;j++)}{delete[]}voidvoidVector::Dis{for(intj=0;j<size;j++)}void{
Vectora(10);Vectorb(a);b.Dis}123123456789b,babuffer,classCAT{CAT(constintGetAge(){return*itsAge;}voidSetAge(intage){*itsAge=age;}int*{itsAge=new}
{deleteitsAge;}void{CATcout<<"a'sage:"<<a.GetAge()<<endl;CATcout<<"a'sage:"<<a.GetAge()<<endl;cout<<"b'sage:"<<b.GetAge()<<endl;cout<<"a'sage:"<<a.GetAge()<<endl;cout<<"b's}a'sa'sa'sage:6b'sage:6a'sage:7b'sb,babuffer,10101314151617181920#include<iostream.h>#include<stdlib.h>temte<classT>classNode{Node<T>*next;//指向后繼節(jié)點(diǎn)的指針Tdata;Node(constT&item,Node<T>*ptrnext=NULL);//構(gòu)造函數(shù)voidInsertAfter(Node<T>*p);pNode<T>*DeleteAfter(void);//刪除本節(jié)點(diǎn)的后繼節(jié)點(diǎn),返回其地址Node<T>*NextNode(void)const;//獲取后繼節(jié)點(diǎn)的地址temte<classT>classLinkedList{Node<T>*front,*rear;Node<T>*prevPtr,*currPtr;intsize;//表中的元素個(gè)數(shù)intposition;ResetNode<T>*GetNode(constT&item,Node<T>item,ptrNextvoidNode(Node<T>*p);//釋放節(jié)點(diǎn)voidCopyList(constLinkedList<T>&L);//將鏈表L//(假設(shè)當(dāng)前表為空)。被拷貝構(gòu)造函數(shù)、operator=LinkedList(void);LinkedList(constLinkedList<T>&L);~LinkedList(void);LinkedList<T>&operator=(constLinkedList<T>&L);//重載賦值運(yùn)算符intListSize(void)const; intListEmpty(void)const;//size0TRUE,FALSEvoidReset(intpos0);currPtrpos//prevPtr,positionvoidNext(void);prevPtrcurrPtrintEndOfList(void)const;//currPtrNULLTRUE,intCurrentPosition(void)const;voidInsertFront(constT&item);itemvoidInsertRear(constT&item);itemvoidInsertAt(constT&item);itemvoidInsertAfter(constT&item);itemTDeleteFront(void);prevPtr、currPtrsizevoidDeleteAt(void);prevPtr、currPtrsizeT&Data(void);datavoidClearList(void);temte<classvoidMergeList(LinkedList<T>*la,LinkedList<T>*lb,LinkedList<T>*{lalb,lcwhile(!la->ListEmpty()&&!lb-while(!la->ListEmpty()&&!lb-{if(la->Data()<=lb- } }}while(!la->ListEmpty(){}while(!lb->ListEmpty(){}}void{Linke
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年玻璃纖維及其制品項(xiàng)目可行性研究報(bào)告
- 2025年中國(guó)農(nóng)業(yè)機(jī)械市場(chǎng)供需預(yù)測(cè)及投資戰(zhàn)略研究咨詢報(bào)告
- 中國(guó)晶鳳尾行業(yè)市場(chǎng)發(fā)展前景及發(fā)展趨勢(shì)與投資戰(zhàn)略研究報(bào)告(2024-2030)
- 2024年中國(guó)煤化工輕油市場(chǎng)供需格局及未來(lái)發(fā)展趨勢(shì)報(bào)告
- 鋼結(jié)構(gòu)工程合同
- 2025年中國(guó)手動(dòng)千斤頂行業(yè)市場(chǎng)發(fā)展前景及發(fā)展趨勢(shì)與投資戰(zhàn)略研究報(bào)告
- 2024年中國(guó)地板蠟行業(yè)調(diào)查報(bào)告
- 2023-2028年中國(guó)電力系統(tǒng)安防行業(yè)發(fā)展前景預(yù)測(cè)及投資戰(zhàn)略咨詢報(bào)告
- 中國(guó)網(wǎng)絡(luò)貨運(yùn)平臺(tái)行業(yè)市場(chǎng)調(diào)研及投資戰(zhàn)略規(guī)劃建議報(bào)告
- 浙江省體育局事業(yè)單位真題2024
- 醫(yī)院物業(yè)服務(wù)招標(biāo)綜合評(píng)分表
- 軟件工程導(dǎo)論(第六版)張海藩-牟永敏課后習(xí)題答案
- 物體打擊應(yīng)急演練總結(jié)
- 環(huán)境保護(hù)局水質(zhì)自動(dòng)在線監(jiān)測(cè)儀、站房及3年運(yùn)營(yíng)維護(hù)服務(wù)招投標(biāo)書范本
- 天然氣管道工程管道焊接施工方案
- GB/T 95-2002平墊圈C級(jí)
- GB/T 16823.3-1997螺紋緊固件擰緊試驗(yàn)方法
- 幼兒園消防安全組織機(jī)構(gòu)圖
- 英語(yǔ)社團(tuán)活動(dòng)課件
- 第三方檢測(cè)市場(chǎng)部管理制度提成方案
- 學(xué)前兒童發(fā)展心理學(xué)-情感
評(píng)論
0/150
提交評(píng)論