在我的 .h 中,我有一个变量,Texture ** skyboxTextures
。我在一种方法中分配了一些纹理指针,并立即使用它们:
Texture *skt[] = {
tleft,
tright,
tfront,
tback,
tup,
tdown
};
skyboxTextures = skt;
for(int i = 0; i < 6; i++)
{
skyboxTextures[i]->load();
}
然后我稍后在另一种方法中尝试再次使用纹理。
Texture *skt[] = skyboxTextures;
// Render the front quad
skyboxTextures[0]->activate();
这是我的问题,我无法再访问我的对象。由于此错误,这将无法编译:
error C2440: 'initializing' : cannot convert from 'Texture **' to 'Texture *[]'
如果我注释掉行 Texture *skt[] = skyboxTextures;
,我得到的只是无效的纹理指针。
最佳答案
您不能分配数组。不幸的是,很难确切知道建议的内容,因为您只提供了一小段代码。但是,我建议阅读此书:http://c-faq.com/aryptr/index.html .
关于c++ - 尝试将 **varname 分配给 *varname[] 时出现问题。 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4950411/