CString Class Research (1)
1. CString Initialize
CString use CStringData structure as a buffer to store data and other information.
| struct CStringData { long nRefs; // reference count int nDataLength; // length of data (including terminator) int nAllocLength; // length of allocation // TCHAR data[nAllocLength]
TCHAR* data() // TCHAR* to managed data { return (TCHAR*)(this+1); } }; |
To Create a New CString Object,
if _AFXDLL is define
MFC的CString对象初始化与空字符串行为解析

本文探讨了MFC中的CString类如何初始化,指出即使未设置值,多个CString对象也可能共享同一个内存缓冲区。当改变共享的空字符串缓冲区值时,所有依赖该缓冲区的对象值也会相应改变。同时,介绍了Empty()函数如何重新分配并初始化为系统定义的空值。
最低0.47元/天 解锁文章
2621

被折叠的 条评论
为什么被折叠?



