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

正文內(nèi)容

面向?qū)ο蟪绦蛟O(shè)計實驗指導(dǎo)書(參考版)

2024-08-04 16:06本頁面
  

【正文】 3.運用文件流,編寫一個實現(xiàn)文件拷貝的C++程序。 // 調(diào)用重載“”運算符函數(shù)}3.編譯、鏈接和執(zhí)行程序?qū)嶒灹曨}1.編寫一個輸出九九乘法口訣表的程序。 array x(d)。 } return out。 k++) outsetw(4)a[j][k]。 j++) { for (int k=0。a){ for (int j=0。 operator (ostream amp。}。out, array amp。 }friend ostream amp。 kn。 jm。class array{ int data[m][n]。實現(xiàn)步驟:1.新建Win32 Console Application程序項目 2.在文件編輯區(qū)窗口編寫如下程序代碼:include include const int m=3。 ()。 } while ((ch=())!=EOF) coutch。 if (!f) { cout”文件不存在或打開失敗!”endl。 cinfn。 char ch, fn[30]。}3.編譯、鏈接和執(zhí)行程序[例102] 編寫一個程序,用于在屏幕上顯示指定的文本文件的內(nèi)容。 cout”八進制數(shù)值:”octnendl。 cinn。實現(xiàn)步驟:1.新建Win32 Console Application程序項目 2.在文件編輯區(qū)窗口編寫如下程序代碼:include include void main(){ int n。提示:設(shè)計一個基類,其中包含描述姓名的數(shù)據(jù)成員、判定是否優(yōu)秀的純虛函數(shù);由此派生出教師類和學(xué)生類,教師類中增添表示論文數(shù)的數(shù)據(jù)成員、重載判定是否優(yōu)秀的成員函數(shù),學(xué)生類中增添表示平均成績的數(shù)據(jù)成員、重載判定是否優(yōu)秀的成員函數(shù)。 pshowarea()。 p=amp。s。 pshowarea()。 p=amp。 square s(“正方形”,10)。void main(){ shape *p。 } void showarea() { coutname”的面積:” *radius*radiusendl。class circle : shape{ float radius。 } void showarea() { coutname”的面積:”width*widthendl。class square : shape{ float width。 } void showarea() { coutname”的面積:”*width*heightendl。public: triangle(char *s,float w,float h):shape(s) { width=w。 }}。 } ~shape() { delete []name。 public: shape(char *s) { name=new char[strlen(s)+1]。解題思路:抽象出一個基類,其中定義一個表示圖形名稱的數(shù)據(jù)成員和一個用于求面積虛函數(shù),由基類派生定義三角形、正方形和圓的類,重載計算面積的成員函數(shù)。提示:設(shè)計一個基類,含有編號和名稱,從它派生出圖書類和讀者類,在讀者類中定義用于描述借書的成員函數(shù)。 delete t1。 t1=new teacher。 teacher *t1。 }}。public: teacher(){ cout”construct teacher”endl。class teacher : public person{ char *major。 } ~student(){ cout”destruct student”endl。class student : public person{ char *departure。 } ~person(){ cout”destruct person”endl。 char *add。include class person{ char *name。 ()。 truck t(10,5000,3,)?!眅ndl ”效率:”efficiency()endlendl。 vehicle::show()。}float truck::efficiency(){ return payload/(payload+weight)。 payload=maxload?!眅ndlendl。 vehicle::show()。}int car::get_passenger(){ return passenger。}void vehicle::show(){ cout”車輪:”wheels”個,” ”自重:”weight”公斤,”。}int vehicle::get_wheels(){ return wheels。vehicle::vehicle(int whe,float wei){ wheels=whe。 void show()。 int get_passenger()。 float payload。}。 int get_passenger()。class car : vehicle{ int passenger。 void show()。 int get_wheels()。 float weight。每個類都有相關(guān)數(shù)據(jù)的輸出方法。2.設(shè)計一個描述矩陣的類,運用運算符重載實現(xiàn)矩陣的和、差、積等運算。int operator –(date amp。提示:在date類中實現(xiàn)如下運算符重載函數(shù):date operator +(int days)。}3.編譯、鏈接和執(zhí)行程序?qū)嶒灹曨}1.設(shè)計一個日期類date,其中包含年、月、日等數(shù)據(jù)成員。 s=t1+t2+t3。 s=t1+t2。 cout”三角形b的面積:”()。 double s=。}double operator +(double d,triangle t){ return d+。 // 友員函數(shù)重載“+”運算符}。 } friend double operator+(triangle,triangle)。 area=sqrt(s*(sa)*(sb)*(sc))。 c=z。 a=x。實現(xiàn)步驟:1.新建Win32 Console Application程序項目2.在文件編輯區(qū)窗口編寫如下程序代碼:include include class triangle{ double a,b,c,area。}3.編譯、鏈接和執(zhí)行程序[例72] 設(shè)計一個三角形類,包含表示三條邊的數(shù)據(jù)成員,編程實現(xiàn)求兩個三角形面積之和。 if (p1==p2) // 調(diào)用運算符重載函數(shù) cout”You are wele!”endl。void main(){ secret m1(“hoesy”), p2。 cinpass。 } int operator ==(secret s) // 運算符“==”重載的成員函數(shù) { return ((strcmp(pass,)==0) ? 1 : 0)。實現(xiàn)步驟:1.新建Win32 Console Application程序項目2.在文件編輯區(qū)窗口編寫如下程序代碼:include class secret{ char pass[16]。 Zi fu chuan pai xu 實驗七 運算符重載實驗?zāi)康膌 掌握運用成員函數(shù)、友元函數(shù)實現(xiàn)運算符重載的方法l 掌握重載運算符函數(shù)的調(diào)用方法實驗示例[例71] 設(shè)計一個密碼類,編程實現(xiàn)比較兩個密碼對象是否一致。 cout”b數(shù)組的元素和:”()endl。 ()。 cout”a數(shù)組的元素和:”()endl。 ()。 arraydouble arr2(b,8)。 double b[]={,}。 coutendl。 jnum。}template class Tvoid arrayT::show(){ int j。 j++) s+=data[j]。 for (j=0。}template class TT arrayT::sum(){ T s=0。 j++) if (data[j]==temp) return data[j]。 } }}template class Tint arrayT::seek(T key){ int j for (j=0。 data[j]=data[m]。 k++) if (data[k]data[j]) m=k。 for (k=j+1。 jnum1。 T temp。}。 T sum()。 } ~array(){} void sort()。public: array(T *d, int n){ data=d。實現(xiàn)步驟:1.新建Win32 Console Application程序項目 2.在文件編輯區(qū)窗口編寫如下程序代碼:include template class Tclass array{ T *data。 cout”b中的最大值:”max(b,6)endl。 char b[]={‘a(chǎn)’,’g’,’k’,’b’,’f’,’e’}。 return temp。 jn。實現(xiàn)步驟:1.新建Win32 Console App
點擊復(fù)制文檔內(nèi)容
法律信息相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1