我知道这个长的字符串可以变得更容易阅读,但我不想这么做!C++和运算符优先级
我想获取像素的颜色,并使用SDL。虽然这不是问题密切相关......
http://www.gamedev.net/topic/502040-sdl-get-pixel-color/
http://www.libsdl.org/docs/html/sdlsurface.html
表明,要获得这个颜色值,你这样做:
Uint32 *pixels = (Uint32 *)surface->pixels;
return pixels[ number ];
嗯,我没有它就是这样,我也想尝试和掌握整个运营商的优先事项..
我试了一下,但我不能让我t与最后一个[]运算符一起工作。
所以...我得到这个:
vector<Class*>* pointer_To_A_Vector_With_Pointers;
Class.h:
vector<Class2*>* get_Another_Vector();
Class2.h
SDL_Surface* sdlSurface;
SDL_Surface.h
has the pixels-array
Uint32 value = *(Uint32*) (* pointer_To_A_Vector_With__Pointers[i]->get_Another_Vector() )[i2]->sdlSurface->pixels;
,它应该是等于说这个:
Uint32 *pixels = (Uint32 *)surface->pixels;
它的工作原理,但只检索像素阵列的第一个颜色。但我想做到这一点(在该行的最后的[数字]):
Uint32 value = *(Uint32*) (* pointer_To_A_Vector_With__Pointers[i]->get_Another_Vector() )[i2]->sdlSurface->pixels[ number ];
换句话说,我希望最后的operator [],sdlSurface->pixels[numbers]
,包括在内。
你去了哪里:http://en.cppreference.com/w/cpp/language/operator_precedence – Shlublu