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

正文內(nèi)容

c上機實驗報告(參考版)

2024-09-22 05:32本頁面
  

【正文】 } 第五篇:上機實驗報告格式 請各位同學按照下列格式寫:否則按照 0分記 上機實驗報告格式 Matlab學習第?次上機實驗報告(第?次) 姓名:???班級 :???上機時間:?????? 將文檔發(fā)到我的郵箱里面 。cout show(v)。} Point Point::operator(int){ return Point(xray,yray)。}。private: double xray。Point operator(int)。 部分參考代碼 Lab8_1 include using namespace std。以實現(xiàn)對 Point類重載 “++” 運算符,定義成函數(shù) Point operator – ()。 實驗步驟 編寫程序定義 Point類,在類中 定義整型的私有成員變量 x,y,定義成員函數(shù) Point operator++()。 定義一個車 (vehicle)基類,有 Run、 Stop等成員函數(shù),由此派生出自行車( bicycle)類、汽車 (motorcar)類,從 bicycle和 motorcar派生出摩托車 (motorcycle)類,它們都有 Run、 Stop等成員函數(shù)。} 實驗 八、多 態(tài)性 2學時 實驗?zāi)康模? 掌握運算符重載的方法 習使用虛函數(shù)實現(xiàn)動態(tài)多態(tài)性。()。 Weight=W。 height=H。class BaseClass{ public: int Number。age=(3)。 void main(void){ int age。 return age。}。 部分參考代碼 Lab7_1 include using namespace std。構(gòu)造派生類 dog,在其成員函數(shù) SetAge(int n)中直接對 age賦值時,會出現(xiàn)類似以下的錯誤提示: error C2248:’age’:cannot access private member declared in class ‘Animal’ error C2248:’age’:cannot access private member declared in class ‘Animal’ 把 age改為公有成員變量后重新編譯就可以了。如果不把 vehicle設(shè)置為虛基類,會有什么問題?編程試試看。自行車類有高度 (height)等屬性,汽車類有座位數(shù) (SeatNum)等屬性。 b)定義一個基類 BaseClass,有整型成員變量 Number ,構(gòu)造其派生類 DerivedClass,觀察構(gòu)造函數(shù)和析構(gòu)函數(shù)的執(zhí)行情況。熟悉不同繼承方式下對基類成員的訪問控制。return 0。} }。 ()。 //定義 RAM對象 CDROM cdrom(1)。//CPU 類 class CPU{ public: //析構(gòu)函數(shù) 17 puter(Rank r,int f,float v){ CPU cpu(r,f,v)。} Lab4_2 include using namespace std。()。()。} void run(){ cout } void stop(){ cout cout cout cout }。 frequency=f。float voltage。cout ” 2131415 public: Rank rank。return a。} int max1(int a,int b,int c){ a=ab?a:b。int max1(int a,int b){ a=ab?a:b。a=max1(1,2)。} void main(void){ int a。a=ac?a:c。return a。相同的地方在于格式、用法等框架上的不變。 實驗原理 C++中函數(shù)的重載使得同樣的函數(shù)名下,只要參數(shù)類型、數(shù)目不同時,即可根據(jù)輸入的數(shù)據(jù)進行相應(yīng)的函數(shù)調(diào)用,使用起來簡單方便。 繼續(xù)執(zhí)行程序,參照上述的方法 ,觀察程序的執(zhí)行順序,加深對函數(shù)調(diào)用和遞歸調(diào)用的理解。 把光標移到語句 answer=fib(n)前,從 Debug菜單單擊 Run To Cursor,在程序運行的 DOS窗口中按提示輸入數(shù)字 10,這時回到可視界面中,光標停在第 11行,觀察一下 n的值。程序名: 。fib(1)=fib(2)=1。 編寫遞歸函數(shù) int fib(int n),在主程序中輸入 n的值,調(diào)用 fib函數(shù)計算 Fibonacci級數(shù)。 在 main()函數(shù)中提示輸入兩個整數(shù) x,y,使用 cin語句得到 x,y的值,調(diào)用 pow(x,y)函數(shù)計算 x的 y次冪的結(jié)果,再 顯示出來。練習重載函數(shù)使用。cout。}。int minut。int day。struct riqi { int year。void main(){ int itype。 } cout using namespace std。 for(i。 } while(i include using namespace std。 ? 將共同的基類設(shè)置為虛基類,這時從不同的路徑繼承過來的同名數(shù)據(jù)成員在內(nèi)存中就只有一個副本,同一個函數(shù)名也只有一個映射。} 運行結(jié)果: 錯誤情況: 思考題 ? 派生一個新的類。()。 =1。int d。int c。int b。int a。源代碼: include using namespace std。 編譯成功后,把 vehicle設(shè)置為非虛基類,再編譯一次,此時系統(tǒng)報錯,無法編譯成功。再從 bicycle和 motorcar派生出摩托車( motorcycle)類,在 main()函數(shù)中測試 這個類。} 運行結(jié)果: debug功能跟蹤程序 lab7_2 的執(zhí)行過程,觀察基類和派生類的構(gòu)造函數(shù)和析構(gòu)函數(shù)的執(zhí)行情況。cout cout int main(){ DerivedClass one。public: BaseClass(){ cout cout class DerivedClass:public BaseClass { private: int b。 源代碼: include using namespace std。} 運行結(jié)果: BaseClass,構(gòu)造其派生類 DerivedClass,在構(gòu)造函數(shù)和析構(gòu)函數(shù)中用 cout輸出提示信息,觀察構(gòu)造函數(shù)和析構(gòu)函數(shù)的執(zhí)行情況。(23)。}。 class dog:public Animal { public: void SetAge(int n){ age=n。public: Animal(){}。} 運行結(jié)果: 正確代碼: include using namespace std。(23)。}。 class dog:public Animal { public: void SetAge(int n){ age=n。public: Animal(){}。錯誤代碼: include using namespace std。構(gòu)造派生類 dog,在其成員函數(shù) SetAge( int n)中直接對 age賦值時,會出現(xiàn)類似以下的錯誤提示: error C2248 : ‘a(chǎn)ge’ : cannot access private member declared in class ‘Animal’ error C2248 :
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1