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

正文內(nèi)容

第六章類成員二-文庫(kù)吧資料

2024-09-09 08:31本頁(yè)面
  

【正文】 id print()。 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 20 作業(yè): (上機(jī) ) (上機(jī) ) 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 21 const對(duì)象與 const成員函數(shù) 本節(jié)討論 const在類中的應(yīng)用 ?const數(shù)據(jù)成員 ?const成員函數(shù) ?const對(duì)象 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 22 const數(shù)據(jù)成員 class Fred { const int size。 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 19 ?對(duì)參數(shù)傳遞而言, C++建議用 const引用傳遞替代值傳遞。 // OK //! *w() = 1。 // Not OK const int* const ccip = w()。 // OK u(cip)。 // OK //! t(cip)。x。x。 // 返回靜態(tài)局部量的地址 } 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 18 int main() { int x = 0。 return amp。 // OK copies value int* ip2 = cip。 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 17 const的應(yīng)用: const指針 4. 傳遞和返回 const指針 char * strcpy(char * dest, const char * src); void t(int*) { } void u(const int* cip) { *cip = 2。class X amp。const class X39。 // Error: f6()是常量,不能被修改 f7(f6())。 //可能會(huì)有 Warning,跟編譯選項(xiàng)有關(guān) f6() = X(1)。 // 正確, f5()返回非 const量; f5().modify()。 x) { // 按值傳遞非 const引用 ()。 // 按值返回 const。 } 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 16 X f5() { X x(2) return x。 X::X(int ii) { i = ii。 void modify()。 class X { int i。 // But this works fine too! } ///:~ 對(duì)內(nèi)部類型來(lái)說(shuō),按值返回 const量并沒有什么特別的意義 。 int main() { const int j = f3()。 } const int f4() { return 1。 // legal but bad practice int main() {} ///:~ ? 注意 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中國(guó)科學(xué)技術(shù)大學(xué)計(jì)算機(jī)系 馬建輝 13 const的應(yīng)用: const參數(shù) 1. 傳遞 const值 void f1(const int i) { i++。 // illegal e const int* w = (int*)amp。 // OK d not const //! int* v = amp。 int* u = amp。 (因?yàn)檫@樣做可能導(dǎo)致通過(guò)非 const指針改變 const對(duì)象的值的后果 ) int d = 1。d。d。 // w是一個(gè)指針,這個(gè)指針是 指向 int的 const指針 注意: C++中, const指針必須賦初值 《面向?qū)ο蟪绦蛟O(shè)計(jì)》 中
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1