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

正文內(nèi)容

團隊學(xué)生技術(shù)交流講座(編輯修改稿)

2025-03-15 12:18 本頁面
 

【文章內(nèi)容簡介】 怎樣實現(xiàn)的呢 ?靜態(tài)綁定與動態(tài)綁定? 綁定 (binding)– 程序自身彼此關(guān)聯(lián)的過程,確定程序中的操作調(diào)用與執(zhí)行該操作的代碼間的關(guān)系。? 靜態(tài)綁定 (early binding)– 綁定過程出現(xiàn)在 編譯 階段,用對象名或者類名來限定要調(diào)用的函數(shù)。? 動態(tài)綁定 (dynamic/later binding)– 綁定過程工作在程序 運行 時執(zhí)行,在程序運行時才確定將要調(diào)用的函數(shù)。“神奇的 ” 執(zhí)行方式 —— 動態(tài)綁定? C++的 虛函數(shù) 在運行時正是通過 動態(tài)綁定 實現(xiàn)多態(tài)機制的。? 動態(tài)綁定是如何實現(xiàn)的呢?? 動態(tài)綁定是通過編譯器運用 虛函數(shù)表 VTBL和 虛表指針 VPTR而實現(xiàn),在運行時通過動態(tài)查詢實現(xiàn)對正確函數(shù)體的綁定。VTBL– 編譯器會為聲明了虛函數(shù)的類建立一個虛函數(shù)表。– VTBL實際上是一個 函數(shù)指針數(shù)組 ,每個虛函數(shù)占用這個數(shù)組的一個入口( slot)。– 一個類只有一個 VTBL,不管它有多少個實例。– 派生類有自己的 VTBL,但是派生類的 VTBL與基類的 VTBL有相同的函數(shù)排列順序,同名的虛函數(shù)被放在兩個數(shù)組的相同位置上。 VPTR? 在創(chuàng)建類實例的時候,編譯器還會在每個實例的內(nèi)存布局中增加一個 VPTR指針,該指針指向本類的 VTBL。 最后,是動態(tài)聯(lián)編? 在調(diào)用此類的構(gòu)造函數(shù)時,在類的構(gòu)造函數(shù)中,編譯器會隱含執(zhí)行 VPTR與 VTBL的關(guān)聯(lián)代碼,將 VPTR指向?qū)?yīng)的 VTBL。這就將類與此類的 VTBL聯(lián)系了起來。? 在調(diào)用類的構(gòu)造函數(shù)時,指向基類的指針此時已經(jīng)變成指向具體的類的 this指針,依靠此 this指針 ,進一步得到正確的 VPTR,即可得到正確的 VTBL,從而實現(xiàn)了多態(tài)性。在此時才能真正與函數(shù)體進行連接,這就是 動態(tài)聯(lián)編 。一個更大的例子 …? includeiostream? usingnamespacestd。? enumnote{middleC,Csharp,Cflat}。//Etc.? classInstrument? {? public:? virtualvoidplay(note)const? {coutInstrument::playendl。}? virtualchar*what()const? {returnInstrument。}? virtualvoidadjust(int){}? }。? classWind:publicInstrument? {? public:? voidplay(note)const? {coutWind::playendl。}? char*what()const{returnWind。}? voidadjust(int){}? }。 ? classPercussion:publicInstrument? {? public:? voidplay(note)const? {coutPercussion::playendl。}? char*what()const{returnPercussion。}? voidadjust(int){}? }。? classStringed:publicInstrument? {? public:? voidplay(note)const? {coutStringed::playendl。}? char*what()const? {returnStringed。}? voidadjust(int){}? }。 一個更大的例子 …? classBrass:publicWind? {? public:? voidplay(note)const? {coutBrass::playendl。}? char*what()const? {returnBrass。}? }。? classWoodwind:publicWind? {? public:? voidplay(note)const? {coutWoodwind::playendl。}? char*what()const? {returnWoodwi
點擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1