第七講:三大構(gòu)造函數(shù):拷貝構(gòu)造,拷貝賦值,析構(gòu)
第七講開始講帶指針的class,以string類為例子講解。

拷貝構(gòu)造,拷貝賦值,class里帶指針,這兩個要自己寫

圖片.png

創(chuàng)建動態(tài)內(nèi)存要析構(gòu)掉,否則會內(nèi)存泄露

深拷貝,淺拷貝

拷貝構(gòu)造函數(shù)

圖片.png

要檢測是否自我賦值

輸出操作符重載,放在全局空間中
第八講:堆,棧與內(nèi)存管理

堆里需要自己delete掉

圖片.png

圖片.png

圖片.png

圖片.png

new的順序

delete的順序

圖片.png

圖片.png
第九講:復(fù)習(xí)string類的實(shí)現(xiàn)過程
整個類:

類

構(gòu)造函數(shù)和析構(gòu)函數(shù)

拷貝構(gòu)造函數(shù)

拷貝賦值函數(shù)
第十講.類模板,函數(shù)模板以及其他

static里沒有this指針,static成員函數(shù)只能處理static成員數(shù)據(jù),static只有一份不屬于對象
從c的觀點(diǎn)看,普通的成員函數(shù)通過this指針來調(diào)用,static成員函數(shù)沒有this指針

要注意分清聲明和定義

單例模式

圖片.png

cout繼承了ostream

類模板

函數(shù)模板

namespace

其他細(xì)節(jié)