Different source files.
I want to have my Init, Update, Draw and CleanUp functions all in different source files, so when the game gets larger I don't end up with long compiling times. Do I need to put every function in a different class, or do I create a class called for example Game and define the functions in different source files like this: Game::Init() etc.?
Thanks,
Have a nice day!
You can put the function bodies for class member functions in separate source files as long as they all include the class definition (which would be in the header file).
Not sure if it will improve compile times though and it will probably prevent some optimisations (splitting the functions across different files, usually the optimiser only optimises each file individually), unless you use compile time linking, which slows down the compilation a lot...
It should't matter if you put those functions all in the same file, in fact it will be faster since you'll only need to compile one file instead of four when doing a full rebuild or make change to more than one functions. Using four files for those function will probably add complexity to your project with no noticable benifits whatsoever, unless you're compiling with a 486 :p
It should't matter if you put those functions all in the same file, in fact it will be faster since you'll only need to compile one file instead of four when doing a full rebuild or make change to more than one functions. Using four files for those function will probably add complexity to your project with no noticable benifits whatsoever, unless you're compiling with a 486 :p
Ha, thanks. I thought it would be quicker, but I will put those functions all in one class in one file ;).
Still, it's a good idea to put different class in different files, but for single functions, i would not recomend it.