| 统计 |
blog名称:人在旅途 日志总数:175 评论数量:505 留言数量:13 访问次数:1678892 建立时间:2005年12月7日 |
生命是过客,人在旅途。奶奶是信基督教的,没啥文化,却养育了四子二女,还带过九个孙辈。老人家对生命的看法就是“人都是客人,迟早要回去的。”就以《人在旅途》来纪念她。

| « | November 2025 | » | | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | | | | | | |
|
| 公告 |
本人上传的源程序中可能引用或使用了第三方的库或程序,也可能是修改了第三方的例程甚至是源程序.所以本人上传的源程序禁止在以单纯学习为目的的任何以外场合使用,不然如果引起任何版权问题,本人不负任何责任. | |

|
本站首页 管理页面 写新日志 退出
调整中...
[微软技术开发]Study the _bstr_t source code |
人在旅途 发表于 2006/1/22 8:33:59 | The _bstr_t is a class, but it encapulate a inner object named m_Data. the m_Data has an reference counter which will be increased and decreased when necessary. And only when the counter is zero the will the Data delete itself. Thus just like CString in MFC, the real data is stored in the inner data meber "m_Data". And the lifecycle of the "m_Data" has nothing to do with the lifecycle of it's father the _bstr_t object. So when a _bstr_t is assigned to the other _bstr_t, only the point of "m_Data" is saved in the other _bstr_t and the counter of "m_Data" is increased, so even when the resource _bstr_t is deleted, the other _bstr_t will still keep it's data safely. And there is no data copy in that operation, so it is quick.So ofcourse, you can define a _bstr_t in a local function's stack and return it with a new _bstr_t to copy it's inner data point, it is safe and quick. As following: _bstr_t str = FunctionReturn_bstr_t_Reference();
|
阅读全文(1953) | 回复(0) | 编辑 | 精华 |
|