c++ - CComPtr 通过引用传递

标签 c++ atl smart-pointers winapi xmllite

我有一种情况需要传递 CComPtr<IXmlReader>通过引用到一个函数。被调用参数是否从被调用参数中获取所有权(或)引用计数增加?

void foo( CComPtr<IXmlReader> & pReader )
{
  // There is no reassignment of the CComPtr.
  // Just call the IXmlReader methods.
}

CComPtr<IXmlReader> pReader;
foo( pReader );

// Is pReader still valid after the function return ?

谢谢。

最佳答案

如果没有重新赋值,为什么是引用参数?

无论如何,引用计数没有变化。是的,返回后CComPtr仍然有效。

关于c++ - CComPtr 通过引用传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10104907/

相关文章:

c++ - XLL 函数参数签名类型

c++ - 在循环内使用 list.push_back(),绕过使迭代器无效

c# - 如何从 C# 调用此 native 方法

c++ - unique_ptr 和带有 C API 的库,带有指向指针函数参数的指针

c++ - 为什么 boost::shared_array 的显式构造函数会导致错误?

c++ - 指向不同类的共享指针数组

C++ fstream 打开

c++ - 在 64 位机器上注册 C++ DLL

com - ATL COM 服务器生命周期

c++ - 直接访问 C++ ATL COM 对象