gpt4 book ai didi

c++ - SDL_Surface 的无效动态表

转载 作者:行者123 更新时间:2023-11-30 03:04:32 28 4
gpt4 key购买 nike

我在创建 SDL_Surface 的动态表时遇到困难。看看这段代码:

SDL_Surface **testA = new SDL_Surface *[2];
for(int i=0;i<2;i++)
testA[i] = new SDL_Surface;
SDL_Surface* testB[2];

就我而言,TestA 和 textB 应该看起来相同。但是 Visual Studio locals 看起来像这样: image

我该如何解决?

最佳答案

试试这个:

    int size=2;
SDL_Surface** testA ;
testA = new SDL_Surface*[size];

for (int i = 0; i < size; i++)
{
surface[i] = NULL; // here, surface[i] is the kth pointer, not an SDL_Surface
// surface[i] = SDL_CreateRGBSurface ( /* set your parameters */ );
}


// Of course, somewhere later in the code, you'll need to free the memory ...
for (i = 0; i < size; i++)
{
SDL_FreeSurface(testA [i]);
testA [i] = NULL;
}

delete testA ;

关于c++ - SDL_Surface 的无效动态表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8551797/

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