WinRT C++ ComPtr GetAddressOf vs &



我刚开始使用Windows 8应用程序的DirectX 11.1,例如:

ComPtr<ID3D11Buffer> constantBuffer;

我想知道的是,使用&constantBufferconstantBuffer.GetAddressOf()是什么区别?

有时它们都可以正常工作,但是有时使用&constantBuffer会导致我的程序违反访问。

您阅读了文档吗?

getAddressof-检索ptr_数据成员的地址,该地址包含指向该comptr表示的接口的指针。

操作员&amp; - 释放与此comptr对象关联的接口,然后检索comptr对象的地址。

最新更新