You might want to post some code that demonstrates exactly what you're doing, both with and without the static.
Right now i don't have any code except a class with variables that gets initiated when the constructor runs.
I am asking this since i need help creating the class i need.
But here is some code for example:
Imagine that these classes are located in different files as well!
Class Loader
{
public:
Loader()
{
SDL_Surface* tile = IMG_Load("tile.png"); //img_load is my own func
SDL_Surface* player = IMG_Load("player.png");
}
SDL_Surface* tile;
SDL_Surface* player;
}
Class Tile: public Loader
{
public:
Tile();
draw(SDL_Surface* screen)
{
//draw out the image tile from Loader
}
}
Class Player: public Loader
{
public:
Player();
draw(SDL_Surface* screen)
{
//draw out the image tile from Loader
}
}
main
{
init()
{
Loader loader;
Tile tile;
Player player;
}
draw
{
tile.draw();
player.draw();
}
init();
draw();
}
In that case isn't tile and player variables inside Loader being created twice. Once for class Tile and once for class Player?