摘要: 從MSDN開始出發(fā)為您講述一種存儲數(shù)據(jù)的過程
理論(MSDN),實(shí)際(Code)
一、文檔的基本特征
文檔類文件是從CDocument繼承而來的。
The CDocument class provides the basic functionality for user-defined document classes. A document represents the unit of data that the user typically opens with the File Open command and saves with the File Save command.
翻譯:文檔類提供用戶自定義文檔類的基本功能。一個(gè)文檔的打開命令和保存命令是數(shù)據(jù)單元特征。
更多內(nèi)容請:
閱讀全文
摘要: 首先先闡明這篇隨筆的意圖,只在告訴讀者,內(nèi)存泄露的神不知鬼不覺,希望能引起大家的注意。
一段代碼的意思如何正確表達(dá),才能不造成內(nèi)存泄露呢?很多朋友經(jīng)常泄露了內(nèi)存但卻查找不到原因。當(dāng)然在CLI/C++中利用托管對象堆上的垃圾收集器是可以更好地避免這一點(diǎn)。但是在更早的版本中,程序員有必要去手動刪除這些相關(guān)資源。否則將在程序關(guān)閉的時(shí)候出現(xiàn)一些錯(cuò)誤。
MFC
現(xiàn)在我們?nèi)ブ剌d一個(gè)虛函數(shù)virtualvoidDeleteContents();用來在銷毀文檔數(shù)據(jù)前調(diào)用框架刪除一些文檔類的數(shù)據(jù),(MSDN:Called by the framework to delete the document's data without destroying the CDocument object itself.)
先批評一段代碼:
閱讀全文