I use SDL_Surface pointers, and I’m wondering if this:
SDL_Surface* Images[8][7];
where some of the individual surface pointers are initialized to NULL in its class constructor and then never used, will take up more memory than if those were kept separate. As you can imagine, using an enumeration would make accessing these surface pointers easier and require no if or switch statements. For example, Images[0][3] to Images[0][7] may all be NULL, NULL, etc. Thanks in advance for replies!
Edit: “kept separate” meaning have a pointer variable name and a smaller array to avoid having NULL as a value for some of the images of which there are less than 7.
Addendum: Thanks everyone for the lightning replies, it’s clear to me now; I’ll go forward with my 2-dimensional array and there will be other arrays as well for other image groups.
Whether you declare your pointers in an array, or individually, one by one, the same amount of memory will be consumed. Of course, if you can declare fewer pointers by declaring them individually, then less space will be consumed.
So the following two lines both reserve space for 3 pointers:
Given the small number of pointers involved in your code sample, you should opt for the approach that results in the most readable code. Only if your array was huge and had only a small proportion of pointers non-null would it be worth getting concerned about the overhead of the unused pointers in the array.