Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Com 远期申报与补偿_Com_Forward Declaration - Fatal编程技术网

Com 远期申报与补偿

Com 远期申报与补偿,com,forward-declaration,Com,Forward Declaration,我有一个简单的例子: struct ID3D11Buffer; class Object3D { Microsoft::WRL::ComPtr<ID3D11Buffer> indBuffer; // use of undefined type 'ID3D11Buffer' in VisualStudio 2013 std::shared_ptr<ID3D11Buffer> a; // ok } struct ID3D11Buffer; 类Object3

我有一个简单的例子:

struct ID3D11Buffer;

class Object3D
{
    Microsoft::WRL::ComPtr<ID3D11Buffer> indBuffer; // use of undefined type 'ID3D11Buffer' in VisualStudio 2013
    std::shared_ptr<ID3D11Buffer> a; // ok
}
struct ID3D11Buffer;
类Object3D
{
Microsoft::WRL::ComPtr indBuffer;//在VisualStudio 2013中使用未定义的类型“ID3D11Buffer”
std::shared_ptr a;//确定
}

正如您所看到的,转发声明与
shared_ptr
一起工作,但与
ComPtr
一起失败。我很好奇为什么?

shared_ptr引用计数在包装对象之外,所以只需要一个指针(这就是为什么删除器不是问题:stackoverflow.com/questions/20985667/…)。COM引用计数需要调用
AddRef
Release
,因此需要定义类型(只是猜测,我没有访问
WRL::ComPtr