gpt4 book ai didi

c++ - 为什么编译器对该数组中的间接级别感到困惑?

转载 作者:行者123 更新时间:2023-11-30 02:53:36 24 4
gpt4 key购买 nike

对我来说似乎很清楚,所以我一定遗漏了什么。

这是句柄数组和每个句柄的声明:

// and the aggregate handle array for the setbufferscall
ID3D11Buffer * m_constantBuffers[NUM_CONSTANT_BUFFERS];

Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantMatrixBuffer;

Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantLightBuffer;

Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantMaterialBuffer;

这就是我想要做的:

// and lastly, we need to aggregate all of these handles into
// one handle array so that it's formatted properly for the
// VSSetConstantBuffers call
m_constantBuffers[0] = m_constantMatrixBuffer.GetAddressOf();
m_constantBuffers[1] = m_constantLightBuffer.GetAddressOf();
m_constantBuffers[2] = m_constantMaterialBuffer.GetAddressOf();

最后,这是编译器所说的:

1>Renderer.cpp(66): error C2440: '=' : cannot convert from 'ID3D11Buffer **' to 'ID3D11Buffer *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Renderer.cpp(67): error C2440: '=' : cannot convert from 'ID3D11Buffer **' to 'ID3D11Buffer *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Renderer.cpp(68): error C2440: '=' : cannot convert from 'ID3D11Buffer **' to 'ID3D11Buffer *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

什么给了?我认为取消引用数组意味着您正在处理数组声明之前的类型,在本例中为 ID3D11Buffer *。

感谢您的阅读以及您能提供的任何智慧

最佳答案

您需要 Get 方法,而不是 GetAddressOf 方法。参见 Get对比GetAddressOf .

关于c++ - 为什么编译器对该数组中的间接级别感到困惑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17842067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com