I know this long string could be made easier to read, but I don't want that!
I want to get the color of a pixel and I'm using SDL. Although this is not very relevant to the question...
http://www.gamedev.net/topic/502040-sdl-get-pixel-color/
http://www.libsdl.org/docs/html/sdlsurface.html
Shows that to get this color value, you do:
Uint32 *pixels = (Uint32 *)surface->pixels;
return pixels[number];
Well I don't have it just like that and I also wanted to try and grasp the whole operator precedence stuff..
I've tried a bit but I can't get it to work with the last []
operator.
So... I got this:
vector<Class*>* pointer_To_A_Vector_With_Pointers;
vector<Class2*>* get_Another_Vector();
SDL_Surface* sdlSurface;
has the pixels-array:
Uint32 value = *(Uint32*) (* pointer_To_A_Vector_With__Pointers[i]->get_Another_Vector())[i2]->sdlSurface->pixels;
And it should be equivalent to saying this:
Uint32 *pixels = (Uint32 *)surface->pixels;
It works, but it only retrieves the very first color of the pixel array. But I want to achieve this (the [number] at the very end of the line):
Uint32 value = *(Uint32*) (* pointer_To_A_Vector_With__Pointers[i]->get_Another_Vector())[i2]->sdlSurface->pixels[ number ];
In other words, I want the very last operator[], sdlSurface->pixels[numbers]
, included.
The precedence of []
is higher than *
, so:
*pointer_To_A_Vector_With__Pointers[i]->get_Another_Vector()
should be:
(*pointer_To_A_Vector_With__Pointers)[i]->get_Another_Vector()
as your variable name suggests.