   Correct game C++ OOP impl. in  main?
  Should it look something like this?:int SDL_main(int argc, char *argv[]){SDL_Init(SDL_INIT_EVERYTHING);// Create the game instance:game = new Game("Klingis - The Game","",640,480,0,0,0);// Run the game instance:int exitCode = game->run();// Delete the game instance:delete game;// Return the exit code:return exitCode;}Or even better/shorter:?int SDL_main(int argc, char *argv[]){SDL_Init(SDL_INIT_EVERYTHING);// Create the local game instance:static Game game("Klingis - The Game","",640,480,0,0,0);return game.run();}No need to supply the Game class code, it should be pretty self-explainary.   
  It really doesn't matter.   ;Quote:Original post by SneftelIt really doesn't matter.But are these a good manner? I think it's very a good way especially the latter. What do you think?   ;  I think what he means is, it doesn't matter.But if you absolutely must choose, either put it on the stack or if on the heap, use a smart pointer to make your Game object exception safe. Back to the original point though.   ;Quote:Original post by programeringQuote:Original post by SneftelIt really doesn't matter.But are these a good manner? I think it's very a good way especially the latter. What do you think?It really doesn't matter. What you have shown there is 0.01% of a complete game. And it's not an important 0.01%. Right now, you are spending more than 0.01% of your time worrying about it, and you should stop doing that.   ;  Do simple things.That means you just declare local variables when you can, and dynamically allocate instances of stuff when you have to. And in fact, you don't even have to give everything a name (i.e. assign it to a variable; you can just use temporaries instead in many cases).But do also be prepared for things to go wrong. RAII is a good way to do this.class SDLIniter {  SDLIniter() { SDL_Init(SDL_INIT_EVERYTHING); }  ~SDLIniter() { /* whatever is necessary to clean up after SDL */ }};int SDL_main(int argc, char *argv[]) {  SDL_Initer initer;  try {    Game("Klingis - The Game","",640,480,0,0,0).run();  } catch (std::exception& e) {    std::cout << e.what() << std::endl;    return -1;  }  // implicit return 0  // and automatic SDL cleanup, whether the exception is thrown or not.};  Shorter isn't always better. It's nice at first to make your main function and game loop look pretty basic but unless you're doing all the error checking under the hood -- problems are bound to happen.   ;  SDL_Init can fail, too.   ;  Everyone who posted in this thread needs to read about the bike shed.   ;Quote:Everyone who posted in this thread needs to read about the bike shed.Nice. I hear like 10 hallway discussions a day at work with this written all over it.   