以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  Program with DOM in C/C++ Using Smart Pointer Class Wrappers  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=24904)


--  作者:binghef117
--  发布时间:12/2/2005 10:26:00 AM

--  Program with DOM in C/C++ Using Smart Pointer Class Wrappers
各位大侠能不能告诉一下哪里可以查到MSXML中Smart Pointer的相关函数的说明资料,中文英文的都可以,我怎么在MSDN里找不到啊?
--  作者:mimimi
--  发布时间:12/2/2005 10:42:00 AM

--  
你装了msxml4.0没有?有文档啊
--  作者:wangjia184
--  发布时间:12/15/2005 1:24:00 PM

--  
Smart Pointer
是内存智能指针

它的文档在MSDN中可以找到:

The template class describes an object that stores a pointer to an allocated object of type Type* that ensures that the object to which it points gets destroyed automatically when control leaves a block.

template <class Type>
class auto_ptr
Parameter
Type
The type of object for which storage is being allocated or deallocated.
Remarks
The template class describes an object that stores a pointer to an allocated object myptr of type Type *. The stored pointer must either be null or designate an object allocated by a new expression. An object constructed with a nonnull pointer owns the pointer. It transfers ownership if its stored value is assigned to another object. (It replaces the stored value after a transfer with a null pointer.) The destructor for auto_ptr<Type> deletes the allocated object if it owns it. Hence, an object of class auto_ptr<Type> ensures that an allocated object is automatically deleted when control leaves a block, even through a thrown exception. You should not construct two auto_ptr<Type> objects that own the same object.

You can pass an auto_ptr<Type> object by value as an argument to a function call. You can return such an object by value as well. Both operations depend on the implicit construction of intermediate objects of class auto_ptr<Type>::auto_ptr_ref<Other>, by various subtle conversion rules. You cannot, however, reliably manage a sequence of auto_ptr<Type> objects with a Standard Template Library container.

它是一个模板类   允许C++实现象 C# Java那样的 自动回收内存
当new一个内存并用auto_ptr关联后,内存的生存周期就由它管理
当auto_ptr析构的时候会释放内存

这样做的效率比 .Net JAVA2 的GC效率高明很多

一个内存的生存周期管理权是可以再分发的~~~
这个模板类是 stl里面的

唯一的不足是不能维护 数组内存  
如果你要的化可以自己写一个
很简单的


如果你还有什么疑问 可以看我的一个封装了
真巧 我没看过那篇E文  不过我也这样做了

地址是这个, 你可以下下去看一下哦~~
http://bbs.xml.org.cn/viewfile.asp?ID=1633


--  作者:vampire_shirley
--  发布时间:12/20/2005 4:46:00 PM

--  
啊,谢谢,我说怎么我调用Release()方法总是出错
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms