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

正文內(nèi)容

面向?qū)ο蟪绦蛟O(shè)計(jì)答案(編輯修改稿)

2024-08-31 18:46 本頁面
 

【文章內(nèi)容簡(jiǎn)介】 {x=a。y=b。} numtype max() {return (xy)?x:y。} numtype min() {return (xy)?x:y。} private: numtype x,y。 }。int main(){Compareint cmp1(3,7)。 cout() is the Maximum of two inteder numbers.endl。 cout() is the Minimum of two inteder numbers.endlendl。 Comparefloat cmp2(,)。 cout() is the Maximum of two float numbers.endl。 cout() is the Minimum of two float numbers.endlendl。 Comparechar cmp3(39。a39。,39。A39。)。 cout() is the Maximum of two characters.endl。 cout() is the Minimum of two characters.endl。 return 0。}實(shí)驗(yàn)五 運(yùn)算符重載一、實(shí)驗(yàn)?zāi)康倪M(jìn)一步了解運(yùn)算符重載的概念和使用方法。掌握幾種常用的運(yùn)算符重載的方法。二、實(shí)驗(yàn)要求定義一個(gè)復(fù)數(shù)類Complex,重載運(yùn)算法“+”,使之能用于復(fù)數(shù)的加法運(yùn)算。將運(yùn)算符重載為普通函數(shù)(非成員、非友元)、成員函數(shù)、友元函數(shù)。根據(jù)要求修改通過函數(shù)來實(shí)現(xiàn)復(fù)數(shù)相加的示例,分別編寫程序,求兩個(gè)復(fù)數(shù)之和。include iostreamusing namespace std。class Complex //定義Complex類{public: Complex(float x=0,float y=0){real=x。imag=y。} //構(gòu)造函數(shù) Complex plex_add(Complex amp。c2)。 //聲明復(fù)數(shù)相加函數(shù) void display() { coutreal39。+39。imag39。i39。endl。 }。 private: float real。 //實(shí)部 float imag。 //虛部}。Complex Complex::plex_add(Complex amp。c2){ Complex c。 = real +。=imag+。return c。}int main(){ Complex plex1(, ), plex2(, )。Complex plex。 //定義3個(gè)復(fù)數(shù)對(duì)象plex=(plex2)。 // 進(jìn)行兩個(gè)復(fù)數(shù)的加運(yùn)算( )。 return 0。}//+10i//普通函數(shù)(非成員、非友元)include iostreamusing namespace std。class Complex {public: Complex(){real=0。imag=0。} Complex(double r,double i){real=r。imag=i。} double get_real()。 double get_imag()。 void display()。 private: double real。 double imag。 }。 double Complex::get_real(){return real。}double Complex::get_imag(){return imag。}void Complex::display(){cout(real,imagi)endl。}Complex operator + (Complex amp。c1,Complex amp。c2){ return Complex(()+(),()+())。}int main(){Complex c1(3,4),c2(5,10),c3。 c3=c1+c2。 coutc3=。 ()。 return 0。} //運(yùn)算符重載為成員函數(shù)include iostreamusing namespace std。class Complex {public: Complex(){real=0。imag=0。} Complex(double r,double i){real=r。imag=i。} Complex operator + (Complex amp。c2)。 void display()。 private: double real。 double imag。 }。Complex Complex::operator + (Complex amp。c2){Complex c。 =real+。 =imag+。return c。}void Complex::display(){cout(real,imagi)endl。}int main(){Complex c1(3,4),c2(5,10),c3。 c3=c1+c2。 coutc1=。()。 coutc2=。()。 coutc1+c2=。()。 return 0。}//將運(yùn)算符重載為友元函數(shù)include iostreamusing namespace std。class Complex {public: Complex(){real=0。imag=0。} Complex(double r){real=r。imag=0。} Complex(double r,double i){real=r。imag=i。} friend Complex operator+ (Complex amp。c1,Complex amp。c2)。 void display()。 private: double real。 double imag。 }。Complex operator+ (Complex amp。c1,Complex amp。c2) {return Complex(+, +)。}void Complex::display(){cout(real,imagi)endl。}int main(){Complex c1(3,4),c2(5,10),c3。 c3=c1+c2。 coutc1=。 ()。 coutc2=。 ()。 coutc1+c2=。 ()。 return 0。}實(shí)驗(yàn)六 繼承和派生一、實(shí)驗(yàn)?zāi)康牧私饫^承在面向?qū)ο蟪绦蛟O(shè)計(jì)中的重要作用。進(jìn)一步理解繼承與派生的概念。掌握通過繼承派生出一個(gè)新的類的方法。了解虛基類的作用和用法。二、實(shí)驗(yàn)要求運(yùn)行程序,分析構(gòu)造函數(shù)與析構(gòu)函數(shù)的調(diào)用順序。程序一:include class A { public: A(){coutA:Constructorendl。}~A(){co
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1