so i am using g++ with code::blocks, and i having trouble with my for loop. gcc will use c++11 (thats not the issue), but i cant find why my for loop doesnt work.
C:\Users\DTSCode\Desktop\SDL\Mirrors of Elixia\main.cpp||In function 'int SDL_main(int, char**)':|
C:\Users\DTSCode\Desktop\SDL\Mirrors of Elixia\main.cpp|13|error: no match for 'operator=' in 'Counter = 0'|
C:\Users\DTSCode\Desktop\SDL\Mirrors of Elixia\main.cpp|13|note: candidates are:|
C:\Users\DTSCode\Desktop\SDL\SDL Dev\include\SDL\SDL_video.h|96|note: SDL_Surface& SDL_Surface::operator=(const SDL_Surface&)|
C:\Users\DTSCode\Desktop\SDL\SDL Dev\include\SDL\SDL_video.h|96|note: no known conversion for argument 1 from 'int' to 'const SDL_Surface&'|
C:\Users\DTSCode\Desktop\SDL\SDL Dev\include\SDL\SDL_video.h|96|note: SDL_Surface& SDL_Surface::operator=(SDL_Surface&&)|
C:\Users\DTSCode\Desktop\SDL\SDL Dev\include\SDL\SDL_video.h|96|note: no known conversion for argument 1 from 'int' to 'SDL_Surface&&'|
C:\Users\DTSCode\Desktop\SDL\Mirrors of Elixia\main.cpp|9|warning: unused variable 'Screen' [-Wunused-variable]|
C:\Users\DTSCode\Desktop\SDL\Mirrors of Elixia\main.cpp|14|warning: no return statement in function returning non-void [-Wreturn-type]|
||=== Build finished: 1 errors, 2 warnings (0 minutes, 0 seconds) ===|
You probably want to store pointers in the vector because that is what the SDL load functions return. It is also necessary if you want to be able to set them to null.
vector<SDL_Surface*> Button(5);
The type of Counter will be the type that you are storing inside Button. If you made the change I suggested above it would be SDL_Surface*. To be able to change the pointer you also want to make it a reference.
> I'm not sure this 2nd option can work. References cannot be NULL...
You misread it.
It simply means that button is the element and no a copy, so changes would affect them.